简体   繁体   中英

running a loop with selenium throws an error after the first iteration

I'm using selenium in python to run through a list of URLS in a CSV file and pull data from each of them.

It works great the first time through the loop, and then the second time, it throws an error:

AttributeError: 'WebDriver' object has no attribute 'Chrome'

scraper code

Anyone know what I'm getting wrong here? Thanks for your help!

Cheers, Ari

I would suggest to initiate browser only once before reading CSV file. Then, in each iteration, use driver.get(url) to navigate to url , something like below,

1) All your imports
2) Initiate chrome (driver, chrome options, etc)
3) read CSV
4) driver.get(url) & rest of your selenium operation for each iteration

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM