I'm attempting to read URLs from a .csv file to begin a loop. My csv file only contains URLs.
While trying to read the URL from the csv file, i'm receiving this error: Message: invalid argument: 'url' must be a string
I've only included relevant code. Thank you in advance for any insight/help.
from csv import reader, writer
driver = webdriver.Chrome()
with open('work2.csv', 'r') as f:
urls = thereader = reader(f)
for url in urls:
driver.get(url)
CodePudding user response:
When you read from a csv file it will read each row in form of list so to get the url you just take the first one.
from csv import reader, writer
driver = webdriver.Chrome()
with open('work2.csv', 'r') as f:
urls = thereader = reader(f)
for url in urls:
driver.get(url[0])