V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2016-09-30 21:34:42 +08:00 · 3229 次点击
    这是一个创建于 2758 天前的主题,其中的信息可能已经有所发展或是发生改变。

    利用 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 条回复    2016-10-02 17:31:06 +08:00
    BiggerLonger
        1
    BiggerLonger  
       2016-10-02 12:42:40 +08:00 via Android
    吧#去掉試一下
    raingolee
        2
    raingolee  
    OP
       2016-10-02 17:27:03 +08:00
    @BiggerLonger 好像可以了,啊啊啊,谢谢啊,困扰我好几天了
    raingolee
        3
    raingolee  
    OP
       2016-10-02 17:31:06 +08:00
    @BiggerLonger 再试一次就不行了,呜呜呜
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   927 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:30 · PVG 04:30 · LAX 13:30 · JFK 16:30
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.