def handle_phantomjs (self):
'''
????phantomjs???
:return: driver
'''
conf = {}
for line in fileinput.input("..//..//abuyun.conf"):
lines = line.replace(' ', '').replace('\n', '').split("=")
conf[lines[0]] = lines[1]
print '??'
# ?????
proxyHost = conf["proxyHost"]
proxyPort = conf["proxyPort"]
# ???????????
proxyUser = conf["proxyUser"]
proxyPass = conf["proxyPass"]
service_args = [
"--proxy-type=http",
"--proxy=%(host)s:%(port)s" % {
"host": proxyHost,
"port": proxyPort,
},
"--proxy-auth=%(user)s:%(pass)s" % {
"user": proxyUser,
"pass": proxyPass,
},
]
phantomjs_path = r"phantomjs"
dcap = dict(DesiredCapabilities.PHANTOMJS)
# ?????UA??????????
ua = self.rad_ua() ##?????UA
dcap["phantomjs.page.settings.userAgent"] = ua
driver = webdriver.PhantomJS(desired_capabilities=dcap, executable_path=phantomjs_path, service_args=service_args)
return driver
评论列表
文章目录