setup.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. from utils.config import config
  2. if config.open_driver:
  3. try:
  4. from selenium import webdriver
  5. except:
  6. pass
  7. def setup_driver(proxy=None):
  8. """
  9. Setup the driver for selenium
  10. """
  11. options = webdriver.ChromeOptions()
  12. options.add_argument("start-maximized")
  13. options.add_argument("--headless")
  14. options.add_argument("--disable-gpu")
  15. options.add_experimental_option("excludeSwitches", ["enable-logging"])
  16. options.add_experimental_option("useAutomationExtension", False)
  17. options.add_argument("blink-settings=imagesEnabled=false")
  18. options.add_argument("--log-level=3")
  19. options.add_argument("--allow-running-insecure-content")
  20. options.add_argument("blink-settings=imagesEnabled=false")
  21. options.add_argument("--no-sandbox")
  22. options.add_argument("--disable-dev-shm-usage")
  23. options.add_argument("--disable-extensions")
  24. options.add_argument("--window-position=-10000,-10000")
  25. if proxy:
  26. options.add_argument("--proxy-server=%s" % proxy)
  27. driver = webdriver.Chrome(options=options)
  28. return driver