def get_driver_chrome(self):
# chromedriver
options = webdriver.ChromeOptions()
proxy = get_proxy()
# NOTE: ??"http"?"https"??????????http?????https
self.proxies["http"] = proxy
self.proxies["https"] = proxy
if proxy:
options.add_argument('--proxy-server=' + proxy)
display = Display(visible=0, size=(800, 800))
display.start()
driver = webdriver.Chrome(executable_path=r"/home/lxw/Software/chromedriver_selenium/chromedriver", chrome_options=options)
"""
# PhantomJS: Not working. why?
driver = webdriver.PhantomJS(executable_path=r"/home/lxw/Downloads/phantomjs/phantomjs-2.1.1-linux-x86_64/bin/phantomjs")
proxy = webdriver.Proxy()
proxy.proxy_type = ProxyType.MANUAL
proxy_str = get_proxy()
if proxy_str:
proxy.http_proxy = proxy_str
# ????????webdriver.DesiredCapabilities.PHANTOMJS?
proxy.add_to_capabilities(webdriver.DesiredCapabilities.PHANTOMJS)
driver.start_session(webdriver.DesiredCapabilities.PHANTOMJS)
"""
# ??????
driver.set_page_load_timeout(self.TIMEOUT)
driver.set_script_timeout(self.TIMEOUT) # ???????????
return driver
评论列表
文章目录