@
zbl430 @
hicdn 请教一下你们 header 有没有做过什么特殊处理啊?
import sys
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
import time
import requests
reload(sys)
sys.setdefaultencoding('utf-8')
headers = { 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept-Language':'en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4,zh-TW;q=0.2,ru;q=0.2',
'Accept-Encoding':'gzip, deflate',
'Connection': 'keep-alive',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0'
}
for key, value in headers.iteritems():
webdriver.DesiredCapabilities.PHANTOMJS['phantomjs.page.customHeaders.{}'.format(key)] = value
webdriver.DesiredCapabilities.PHANTOMJS['phantomjs.page.settings.userAgent'] = 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:47.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36'
print 'yeah'
url = '
http://wsjs.saic.gov.cn/'driver = webdriver.PhantomJS()
driver.get(url)
driver.maximize_window()
time.sleep(5)
driver.save_screenshot('fk1.png')
我是这样访问首页的, 不知道哪里有问题, 能不能指点一下,谢谢了。