更新时间:2022-12-11 21:41:30
最新版本( 1.9.1 的a>)是2013年5月5日发行的.拉取请求已合并 2013年6月23日.
The latest version (1.9.1) of PhantomJS is release Jun/5/2013. The pull request is merged Jun/23/2013.
如果您使用的是PhantomJS 1.9.1版本,则自定义标头将不起作用.
If you are using 1.9.1 version of PhantomJS, custom headers will not work.
您必须自己构建phantomjs或等到phantomjs合并ghostdriver更改并发布新版本.
You have to build phantomjs yourself or wait until phantomjs merge ghostdriver changes and release new version.
使用新构建的phantomjs我得到以下结果:
Using newly build phantomjs I got following result:
from selenium import webdriver
webdriver.DesiredCapabilities.PHANTOMJS['phantomjs.page.customHeaders.Accept-Language'] = 'ru-RU'
driver = webdriver.PhantomJS()
driver.get('http://httpbin.org/headers')
print(driver.page_source)
...
{
"headers": {
"Connection": "close",
"Host": "httpbin.org",
"Accept-Encoding": "gzip",
"Accept-Language": "ru-RU",
"User-Agent": "Mozilla/5.0 (Unknown; Linux i686) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.10.0 (development) Safari/534.34",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
}
...
使用PhantomJS 1.9.2 + .