3

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.
Bronson77
  • 251
  • 2
  • 3
  • 11

1 Answers1

2

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
Erfan
  • 40,971
  • 8
  • 66
  • 78