I tried writing some code to find and print the price of a specific book but when I ran the code it returned £54.23
.
What is Â
? How do I make it go away?
From my understanding I'm supposed to copy the CSS path for soup.select
but since this option did not show up on chrome I copied selector. Could this be responsible for Â
?
Here's my Python code:
import requests
from bs4 import BeautifulSoup
user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36'
headers = {'User-Agent': user_agent}
res_obj = requests.get('http://books.toscrape.com/')
res_obj.raise_for_status()
soup = BeautifulSoup(res_obj.text, 'html.parser')
sapiens_price = soup.select('#default > div > div > div > div > section > div:nth-child(2) > ol > li:nth-child(5) > article > div.product_price > p.price_color')
print(sapiens_price[0].text)