setup.py 1.0 KB

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