def configure_browser(options):
logging.info("Configuring browser")
opts = webdriver.ChromeOptions()
# Chrome user agent will download files for us
#opts.add_argument("user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36")
# This user agent will give us files w. download info
opts.add_argument("user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko")
chromePrefs = {
"profile.default_content_settings.popups":"0",
"download.default_directory":options.dw_dir}
opts.add_experimental_option("prefs", chromePrefs)
if sys.platform == 'win32':
chromedriver_path = "chromedriver.exe"
else:
chromedriver_path = "./chromedriver"
logging.info("Starting browser")
driver = webdriver.Chrome(chrome_options=opts,
executable_path=chromedriver_path)
return driver
评论列表
文章目录