import requests
from bs4 import BeautifulSoup
url = "https://www.amazon.in/dp/B0748G1QLP?pf_rd_p=014b5857-ee84-4ef8-b74d-aa815486475f&pf_rd_r=BX8E2AVBTMKJKR02364R"
head = {"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"}
page = requests.get(url, headers = head)
page
<Response [200]>
soup = BeautifulSoup(page.content, "html.parser")
price = soup.find(id="priceblock_ourprice").get_text().strip()
title = soup.find(id="productTitle").get_text().strip()
print(title)
Bose Sound Sport Free Truly Wireless Sport Headphones (Black)
type(price)
str
int(price)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-20-42ba99a07096> in <module>
----> 1 int(price)
ValueError: invalid literal for int() with base 10: '₹\xa018,990.00'
float(price[2:].replace(",",""))
18990.0
import jovian
jovian.commit()
[jovian] Saving notebook..