Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Selenium python loop over links

Hi I want to loop over links I am retrieving from an access database and then get each link a number of times my code is as follows the problem is it gets to the second link and stops

count=0
for link in df['Links']:
    while count < 2:
        driver = webdriver.Chrome(executable_path=path, options=options)
        driver.get("" + link)
        time.sleep(100)
        driver.close()
        count = count + 1

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I think it makes more sense to use a for-loop in this case:

for link in df['Links']:
    for _ in range(2):
        driver = webdriver.Chrome(executable_path=path, options=options)
        driver.get("" + link)
        time.sleep(100)
        driver.close()

_ is a variable, much like x or count would act, but conventionally it’s used when the variable is not used, such as this case.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading