Home python Selenium parser. How to optimize chrome and chromedriver?

Selenium parser. How to optimize chrome and chromedriver?

Author

Date

Category

I use Selenium and Chrome Driver to open two tabs to the desired page and faced with such a problem:

During the passage through the chrome pages, something keeps in RAM and does not want to delete it, until it fills it completely and never break (hangs).

I thought it was a cache that the browser remembers all the tabs open for the session, etc. etc. Therefore, I cleaned everything that it is possible to clear: cache, cookies, history (I tried and during the work of Parser); Includes disable cache and other functions in Network, reset the arrays that store tabs in the code, but nothing helped. RAM, as filled, and continues. As a result, I rested in + -250 entries in the database. And you need to resign a few thousand.

What to do?




Answer 1

By observations, it became clear that RAM was filled due to
Chromedriver.exe

The solution was the creation of a counter with a restart driver every n records.
Example of my counter:

i = -1
For d in url:
  Driver.get (D ['href'])
  href_stat = d.get ('href')
  I + = 1
  Print (I)
  IF i == 20:
    Driver.Quit ()
    Chromedriver = "C: / Projects / Parser / Chromedriver"
    Driver = WebDriver.chrome (Chromedriver)
    Driver.get (D ['href'])
    i = 0.

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions