Jovian
⭐️
Sign In
In [1]:
import requests
In [2]:
from bs4 import BeautifulSoup
In [11]:
url = "https://www.amazon.in/dp/B0748G1QLP?pf_rd_p=014b5857-ee84-4ef8-b74d-aa815486475f&pf_rd_r=BX8E2AVBTMKJKR02364R"
In [12]:
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"}
In [13]:
page = requests.get(url, headers = head)
In [14]:
page
Out[14]:
<Response [200]>
In [15]:
soup = BeautifulSoup(page.content, "html.parser")
In [18]:
price = soup.find(id="priceblock_ourprice").get_text().strip()
In [17]:
title = soup.find(id="productTitle").get_text().strip()
print(title)
Bose Sound Sport Free Truly Wireless Sport Headphones (Black)
In [19]:
type(price)
Out[19]:
str
In [20]:
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'
In [26]:
float(price[2:].replace(",",""))
Out[26]:
18990.0
In [ ]:
import jovian
jovian.commit()
[jovian] Saving notebook..
In [ ]: