I use Selenium and Firefox webdriver with python to scrape data from a website.
But in the code, I need to access this website more than 10k times and it consumes a lot of RAM to do that.
Usually, when the script access this site 2500 times, it already consumes 4gb or more of RAM and it stops to work.
Is it possible to reduce memory RAM consumption without close browser session?
I ask that because when I start the script, I need to log manually on the site(two-factor autentication, the code is not shown below) and if I close the browser session, I will need to log in the site again.
for itemLista in lista:
driver.get("https://mytest.site.com/query/option?opt="+str(itemLista))
isActivated = driver.find_element_by_xpath('//div/table//tr[2]//td[1]')
activationDate = driver.find_element_by_xpath('//div/table//tr[2]//td[2]')
print(str(isActivated.text))
print(str(activationDate.text))
indice+=1
print("numero: "+str(indice))
file2.write(itemLista+" "+str(isActivated.text)+" "+str(activationDate.text)+"\n")
#close file
file2.close()