zoukankan      html  css  js  c++  java
  • Python+Selenium+PhantomJS下载JavaScript异步加载网页

     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()    
  • 相关阅读:
    CentOS-Docker安装RabbitMQ集群(rabbitmq:3.7.16-management)
    Xcode Shortcuts
    In App Purchase
    CoreData
    Sandbox 文件存放规则
    在 mac os 上搭建 git server
    Git
    Git and Xcode
    心算技巧
    AppleScript
  • 原文地址:https://www.cnblogs.com/gui0901/p/5057198.html
Copyright © 2011-2022 走看看