7

I have rows of links contained in a dataframe.

df = pd.DataFrame()

I need to iterate over the rows of links in the dataframe one at a time so I can perform selenium tasks on each link separately. It should iterate over these rows in a loop until there are no more rows in the dataframe.

     links
0    http://linkone
0    http://linktwo
0    http://linkthree

My logic is as follows

Loop
    Get http://linkone in first row of dataframe
    Use selenium to perform tasks, such as driver.get(http://linkone)
    Gather data from HTML from http://linkone

    Continue loop and get row 2, row 3, etc.
0

1 Answer 1

3

In this case you dont need iterrows(), just use a for loop.

Simply use a for loop:

for link in df.links:
    print(link)
    print('do something with selenium')

http://linkone
do something with selenium
http://linktwo
do something with selenium
http://linkthree
do something with selenium
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for your help. That was simple enough!
No problem, happy coding!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.