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

相關文章
相關標籤/搜索