先要导入模块
from selenium.webdriver import DesiredCapabilities
from selenium import webdriver
headers={'user-agent':'',
'referer':,
‘’:‘’
}
desired_capabilities = DesiredCapabilities.PHANTOMJS.copy()
for key,value in headers.iteritems():
desired_capabilities['phantomjs.page.customHeaders.{}'.format(key)] = value
url=‘要访问的网址’
driver=webdriver.PhantomJS(executable_path='D:/phantomjs.exe',desired_capabilities=desired_capabilities)
driver.get(url)
print driver.page_source
#ok,到这一步已经带着头部信息里的数据进行访问了,关于动态添加ip的,本人正在研究,如有知道的,可以留言明示,谢谢!