def get_browser(sport, debug=False):
"""
Use selenium and chromedriver to do our website getting.
Might as well go all the way.
:param debug: whether to set the browser to debug mode
:param headless: go headless
:return:
"""
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--user-agent=%s' % USERAGENT)
webdriver.DesiredCapabilities.CHROME["userAgent"] = "ignore"
prefs = {"download.default_directory" : root_data_dir.format(sport=sport)}
chrome_options.add_experimental_option("prefs",prefs)
browser = webdriver.Chrome(chrome_options=chrome_options)
browser.implicitly_wait(10) # wait up to 10s for an element if it's not instantly available
return browser
评论列表
文章目录