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
leartang
V2EX  ›  Python

Phantomjs proxy 问题

  •  
  •   leartang · 2019-07-12 11:43:28 +08:00 via Android · 1157 次点击
    这是一个创建于 1751 天前的主题,其中的信息可能已经有所发展或是发生改变。

    service_args = [

    "--proxy-type=http",
    
    "--proxy=218.91.112.196:9999",
    
    "--ssl-protocol=any",
    
    ]
    

    dcap = dict(DesiredCapabilities.PHANTOMJS)

    dcap["phantomjs.page.settings.userAgent"] = ("Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Mobile/15E148 Safari/604.1")

    driver = webdriver.PhantomJS(desired_capabilities=dcap,service_args=service_args)

    driver.set_page_load_timeout(30)

    try:

    driver.get("http://test.com")
    
    print(driver.page_source)
    

    except:

    pass
    

    driver.quit()

    service_args=service_args 加上这一个就返回

    不加代理就能正常读取内容 试了几个代理都不行,Mayday Mayday !

    Selenium 2.48 Phantomjs2.1.1 Python3.7 Windows10

    1 条回复    2019-07-12 23:03:02 +08:00
    leartang
        1
    leartang  
    OP
       2019-07-12 23:03:02 +08:00 via Android
    有没有大神,求解答…
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2766 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 06:36 · PVG 14:36 · LAX 23:36 · JFK 02:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.