How to reduce chromedriver cpu usage in selenium python?

Viewed 1012

i'm trying to automate login and scraping data using selenium in python im using chromedriver as a driver. but i want to do that with 5 account, im still figuring out what is the best method to do.

for now, i create the code in python file then i create batch file to run the python. so i can open multiple batch file with multiple account.

but the problem is cpu usage is too high so im just able to do with 3 account.

Troubleshooting i do so far is changing options to make chrome headless using this code

    self.options = webdriver.ChromeOptions()
    self.options.headless = True
    self.options.add_argument(f'user-agent={user_agent}')
    self.options.add_argument("--window-size=1920,1080")
    self.options.add_argument('--ignore-certificate-errors')
    self.options.add_argument('--allow-running-insecure-content')
    self.options.add_argument("--disable-extensions")
    self.options.add_argument("--proxy-server='direct://'")
    self.options.add_argument("--proxy-bypass-list=*")
    self.options.add_argument("--start-maximized")
    self.options.add_argument('--disable-gpu')
    self.options.add_argument('--disable-dev-shm-usage')
    self.options.add_argument("--FontRenderHinting[none]")
    self.options.add_argument('--no-sandbox')
    self.options.add_argument('log-level=3')
    self.driver = webdriver.Chrome(executable_path="chromedriver.exe", options=self.options)

but still cant achieve my target(5 account). is there anything i can do to achieve my target?

Thanks.

1 Answers
self.options.add_argument('--headless')

this will make the driver run way faster then before

Related