Linux下Selenium+PhantomJS的问题
今日Tbor登录linux大陆手拿Selenium+PhantomJS准备打怪升级,
尼玛, 没有数据?
<html><head></head><body></body></html>
Tbor怀疑自己昨晚太过劳累, 于是他。。。睡着了!每攻击一次睡一觉。男人嘛, 休息还是挺重要的!
import time from selenium import webdriver driver = webdriver.PhantomJS(executable_path="/home/Tbor/Desktop/phantomjs-2.1.1-linux-x86_64/bin/phantomjs") driver.get("https://www.baidu.com/") time.sleep(3) print driver.page_source
结果他发现, 这完全改变不了他肾亏的事实!
<html><head></head><body></body></html>
这可不是Tbor想要的, 第一反应可能自己被发现了, Tbor怀疑自己的脑袋(请求头)辨识度太高, 于是Tbor抬起自己手中的Selenium+PhantomJS启动伪装术
import time from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities dcap = DesiredCapabilities.PHANTOMJS.copy() header = { "Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", "Accept-Encoding":"gzip, deflate, br", "Accept-Language":"zh-CN,zh;q=0.9", "Cache-Control":"max-age=0", "Connection":"keep-alive", "Cookie":"lsv=globalTjs_48e30dd-wwwTcss_cb39b0d-wwwBcss_483ee4a-framejs_2d8c954-globalBjs_8c0c610-sugjs_ddbaa53-wwwjs_5bf2601; plus_cv=1::m:caddfa4f; MSA_WH=320_568; ispeed_lsm=2; sug=3; sugstore=0; ORIGIN=0; bdime=0; BAIDUID=1A18D1CA8AAB7B0DDAAA0CC1CB239A9A:FG=1; BIDUPSID=1A18D1CA8AAB7B0DDAAA0CC1CB239A9A; PSTM=1524476137; B64_BOT=1; H_PS_645EC=a4beKut49tLxOMARLfm%2Fo6SdsqBYpvVfsiXBqLEPqjmyN6v9HOy5k06aQp8; BD_CK_SAM=1; PSINO=6; BDRCVFR[c3DJb-79z0f]=mk3SLVN4HKm; BD_HOME=0; H_PS_PSSID=26254_1424_21085_26106; BD_UPN=12314353", "Host":"www.baidu.com", "Upgrade-Insecure-Requests":"1", "User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36", } for key, value in header.items(): dcap['phantomjs.page.customHeaders.{}'.format( key)] = value driver = webdriver.PhantomJS(executable_path="/home/Tbor/Desktop/phantomjs-2.1.1-linux-x86_64/bin/phantomjs") driver.get("https://www.baidu.com/", desired_capabilities=dcap) time.sleep(3) print driver.page_source
一阵激斗, 烟雾散去
<html><head></head><body></body></html>
尼玛, 这么强悍的吗?不过Tbor什么场面没见过, 于是他跑了。。
Tbor回到了windows大陆, 用同样的招式
难道是因为自己英俊的脸庞, 于是Tbor回到家赶紧找镜子吗看看自己是否又变帅了!因为他觉得只有这个原因, 没有其他解释!他找到镜子, 镜子旁边, 他翻开了一本古籍!
“”PhantomJS使用的加密方式是SSLv3,有些网站用的是TLS。。。“”
是否是因为加密方式的区别?
于是他
import time from selenium import webdriver driver = webdriver.PhantomJS(service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any'],executable_path="/home/Tbor/Desktop/phantomjs-2.1.1-linux-x86_64/bin/phantomjs") driver.get("https://www.baidu.com/") time.sleep(3) print driver.page_source
于是他。。。
相关推荐
farwang 2020-11-25
星愿心愿 2020-11-24
tianhuak 2020-11-24
zhjn0 2020-11-24
昭君出塞 2020-11-23
bluecarrot 2020-11-23
linuxwcj 2020-10-21
以梦为马不负韶华 2020-10-20
彼岸随笔 2020-10-20
yutou0 2020-10-17
applecarelte 2020-10-16
ourtimes 2020-10-16
waterhorse 2020-09-19
MRFENGG 2020-11-11
rainandtear 2020-10-30
kyssfanhui 2020-10-20
liuhangtiant 2020-10-20