使用selenium+chrome能抓取数据,而selenium+phantomjs抓取数据为空?

爬虫采用 使用selenium+chrome能抓取数据,而selenium+phantomjs抓取数据为空,不知道原因出在哪儿,求助各位

遇到同样的问题,Chrome 可以正常返回数据,PhantomJS返回。加了useragent 仍然不行。后面抓一下包,看看PhantomJS都发送了什么出去,可能要修改phantomjs代码才行

加了header,还是不行

不是headers的问题,是加密方式的问题,PhantomJS使用的加密方式是SSLv3,有些网站用的是TLS。神奇的Google:Python: Selenium with PhantomJS empty page source(https://link.zhihu.com/?target=https%3A//stackoverflow.com/questions/23581291/python-selenium-with-phantomjs-empty-page-source)

  1. 添加参数 --ignore-ssl-errors=true --ssl-protocol=any 就好了

  2. 试试browser=webdriver.PhantomJS(service_args=[’–ssl-protocol=any’, ‘–ignore-ssl-errors=true’])

  3. 用phantomjs的时候添加一下user-agent,可能网站做反爬机制。

转载https://www.zhihu.com/question/59084582

猜你喜欢

转载自blog.csdn.net/shuidefu/article/details/89550290
今日推荐