I have CSV file containing a list of links, i stored those values in a list and then pass the list values as the URL for the page i need to get the data from and it works for the first list item but not for the list items after that. Although it works if the URL is directly passed as a string to the variable i'm sorting the URL in is there any way to fix this please help?
Here is the code:
data = pd.read_csv("cur_hp_printer_name_links.csv")
list_of_links = data['links'].tolist()
link_no = 0
specs = []
spec = {}
while link_no < 2:
URL = list_of_links[link_no]
r = requests.get(URL)
soup = BeautifulSoup(r.content, 'html5lib')
table = soup.find('div', attrs={'class': 'column main'})
for rows in table.findAll('div', attrs={'class': 'page-title-wrapper product'}):
spec['Product_name'] = rows.span.text
specs.append(spec)
print(spec)
link_no += 1
here is the output
C:\Users\dhanush\Desktop\stuff\pycharm projects\venv\Scripts\python.exe" "C:/Users/dhanush/Desktop/stuff/pycharm projects/test.py"
{'Product_name': 'HP DeskJet Ink Advantage 1115 Printer'}
Process finished with exit code 0
here the part right under where the name of the product is, there's supposed to be another name which hasn't been printed