browser_automation.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:sportsball 作者: jgershen 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号