Linux下Selenium+PhantomJS的问题

今日Tbor登陆linux大陆手拿Selenium+PhantomJS准备打怪升级,
尼玛, 没有数据?css

<html><head></head><body></body></html>html

Tbor怀疑本身昨晚太过劳累, 因而他。。。睡着了!每攻击一次睡一觉。男人嘛, 休息仍是挺重要的!linux

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

结果他发现, 这彻底改变不了他肾亏的事实!web

<html><head></head><body></body></html>windows

这可不是Tbor想要的, 第一反应可能本身被发现了, Tbor怀疑本身的脑壳(请求头)辨识度过高, 因而Tbor抬起本身手中的Selenium+PhantomJS启动假装术app

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大陆, 用一样的招式加密

clipboard.png

难道是由于本身英俊的脸庞, 因而Tbor回到家赶忙找镜子吗看看本身是否又变帅了!由于他以为只有这个缘由, 没有其余解释!他找到镜子, 镜子旁边, 他翻开了一本古籍!spa

“”PhantomJS使用的加密方式是SSLv3,有些网站用的是TLS。。。“”
是不是由于加密方式的区别?code

因而他

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

因而他。。。
clipboard.png

相关文章
相关标签/搜索