Issue
I have to ask somethings. I'm learning Beautiful Soup 4 and I'm trying get data from Amazon. But I have an issue. Please help me.
URL = "https://www.amazon.com.tr/MSI-GEFORCE-GAMING-Siyah-Normal/dp/B096SLRQRY/ref=sr_1_5?keywords=rtx+3080&qid=1666449658&qu=eyJxc2MiOiI3LjA0IiwicXNhIjoiNS45OCIsInFzcCI6IjQuODQifQ%3D%3D&sr=8-5"
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36 Edg/106.0.1370.52", "Accept-Encoding": "gzip, deflate, br", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "Dnt": "1", "Connection":"Close", "Upgrade-Insecure-Requests":"1"}
page = requests.get(URL, headers = headers)
soup = BeautifulSoup(page.content, "html.parser")
soup1 = BeautifulSoup(soup.prettify(), "html.parser")
title = soup1.find(id="productTitle").getText()
price = soup1.find(id = "corePriceDisplay_desktop_feature_div").getText()
print(title)
print(price)
This is my code. This code turned this
I know this is Amazon's website's problem. But I want to fix it.
Solution
Okey, I found a way like
print(price.strip()[:11])
It's enough.
Answered By - frkakl
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.