推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
raingolee
V2EX  ›  Python

PhantomJS , selenium 使用过程无法渲染某些 js 页面,求各位大哥帮忙看看

  •  
  •   raingolee · Sep 30, 2016 · 3872 views
    This topic created in 3648 days ago, the information mentioned may be changed or developed.

    利用 PhantomJS 去请求几个微博的 url ,发现没法渲染某个特定的 js 页面

    以下为测试的伪代码,麻烦各位大哥可以帮忙看看

    
    from selenium import webdriver
    from selenium.webdriver import DesiredCapabilities
    
    desired_capabilities \
    = DesiredCapabilities.PHANTOMJS.copy()
    
    desired_capabilities['phantomjs.page.customHeaders.User-Agent'] \
    = headers['User-Agent']
    
    desired_capabilities['phantomjs.page.customHeaders.Cookie'] = headers['Cookie']
    
    driver = webdriver.PhantomJS(desired_capabilities=desired_capabilities)
    
    driver.get(url)
    htmlTag = driver.page_source
    
    

    这时候我传了以下两个 url 进去,然后第二个 url 无论怎么请求返回的 html 都是没有渲染过的

    #可以渲染
    urlUser = 'http://weibo.com/sandra0314?refer_flag=1087030101_417'
    
    #不能渲染
    urlTag = 'http://d.weibo.com/1087030002_2975_2012_0#'
    

    望得到大家帮助,谢谢

    3 replies  •  2016-10-02 17:31:06 +08:00
    BiggerLonger
        1
    BiggerLonger  
       Oct 2, 2016 via Android
    吧#去掉試一下
    raingolee
        2
    raingolee  
    OP
       Oct 2, 2016
    @BiggerLonger 好像可以了,啊啊啊,谢谢啊,困扰我好几天了
    raingolee
        3
    raingolee  
    OP
       Oct 2, 2016
    @BiggerLonger 再试一次就不行了,呜呜呜
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   967 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 18:41 · PVG 02:41 · LAX 11:41 · JFK 14:41
    ♥ Do have faith in what you're doing.