-2

I am trying to run this code to read csv file then take an item number in the csv and search for it in a website, then give me URL of the results.

The issue is that it is unable to find the csv file.

Here's the code:

url = 'https://khusheimstore.com/?wc-ajax=aws_action'
urlist= []

with open ('./book1', mode='r') as file:
    csvfile = csv.reader(file)

    for line in csvfile:
        myobj = { 'keyword': line }
        resultlist= requests.post(url, data=myobj)
        for result in resultlist.product:
            urlist.append(result.url)

This the error message I received, although the file is there in the same folder of the code!

FileNotFoundError: [Errno 2] No such file or directory: './book1'
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

1 Answers1

0

you might missed adding extension .csv in file name try this

url = 'https://khusheimstore.com/?wc-ajax=aws_action'
urlist= []

    
with open ('./book1.csv', mode='r') as file:
    csvfile = csv.reader(file)

    for line in csvfile:    
        myobj = { 'keyword': line }
        resultlist= requests.post(url, data=myobj)
        for result in resultlist.product:
            urlist.append(result.url)
Kunal Sharma
  • 416
  • 3
  • 12