lundi 23 décembre 2019

Very basic web scraping query for you fine folk

Just working on a small project for which I'd like to web scrape the price of a particular item. I've never done this before and I'm having difficulty using a few methods.

This is the webpage in question: https://www.made.com/keira-office-chair-cloud-grey-and-copper

and this is the element in question:

£149 £149 The code I am trying is as follows: import requests, bs4

page = requests.get(URL,headers={"User-Agent":"Defined"})
page.raise_for_status()
soup = bs4.BeautifulSoup(page.content, 'html.parser')
price = soup.find('ProductPrice__Price-rtg8id-1 jYfukd').get_text()
print(price)```


The error I receive is: 
ttributeError: 'NoneType' object has no attribute 'get_text'

 I had a look around it appears an easier method of doing what I am attempting is to use a CSS selector, however I have tried that (perhaps incorrectly) and when I run my script, it just returns '[]'.

Could somebody kindly explain what I am doing wrong, or what I should be looking for? Thanks a lot and Merry Christmas.



Aucun commentaire:

Enregistrer un commentaire