Python+Selenium+PhantomJS下载JavaScript异步加载网页

 # -*- coding: utf-8 -*-
from selenium import webdriver
import selenium.webdriver.support.ui as ui
from selenium.webdriver.common.keys import Keys def test1():
DEMO_PAGE = 'http://www.court.gov.cn/zgcpwsw/Html_Pages/eae8/eae8166f-1c9e-4a03-a10d-b86dde502047.html' driver = webdriver.PhantomJS('C:/phantom/phantomjs-2.0.0-windows/bin/phantomjs.exe')
driver.get(DEMO_PAGE) wait = ui.WebDriverWait(driver,10)
wait.until(lambda driver: driver.find_element_by_xpath("//div[@id='DivContent']/div[1]/a"))
divs = driver.find_elements_by_xpath("//div[@id='DivContent']/div") for div in divs:
div_text = div.text
print div_text
driver.quit test1()
上一篇:SAP S4 Finance6个支持企业实时财务管理的主要创新领域


下一篇:python 协程、I/O模型