Posted on 10th September 2024|140 views
import requests
from bs4 import BeautifulSoup
URL = 'https://www.amazon.in/Acer-15-6-inch-Graphics-Obsidian-AN515-55/dp/B088FLY29Z/ref=sr_1_2?crid=2JYW7GB0Y0EAL&dchild=1&keywords=acer+nitro+5+2020&qid=1597467216&sprefix=acer+%2Caps%2C282&sr=8-2'
headers = {'User Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36'}
page = requests.get(URL, headers=headers)
soup = BeautifulSoup(page.content,'html.parser')
print(soup.prettify())
title = soup.find(id="productTitle")
if title:
title1 = title.get_text
print(title1)
price = soup.find(id="priceblock_ourprice")
if price:
price1 = price().get_text
print(price1)
converted_price = float(price[0:5])
print(converted_price)