1 # -*- coding: utf-8 -*- 2 from selenium import webdriver 3 import selenium.webdriver.support.ui as ui 4 from selenium.webdriver.common.keys import Keys 5 6 def test1(): 7 DEMO_PAGE = 'http://www.court.gov.cn/zgcpwsw/Html_Pages/eae8/eae8166f-1c9e-4a03-a10d-b86dde502047.html' 8 9 driver = webdriver.PhantomJS('C:/phantom/phantomjs-2.0.0-windows/bin/phantomjs.exe') 10 driver.get(DEMO_PAGE) 11 12 wait = ui.WebDriverWait(driver,10) 13 wait.until(lambda driver: driver.find_element_by_xpath("//div[@id='DivContent']/div[1]/a")) 14 divs = driver.find_elements_by_xpath("//div[@id='DivContent']/div") 15 16 for div in divs: 17 div_text = div.text 18 print div_text 19 driver.quit 20 21 test1()