I'm webscraping a product in Amazon's website with BeautifulSoup, but when I run the code:
import requests
from bs4 import BeautifulSoup
import smtplib
URL = 'https://www.amazon.com.br/What-Wonderful-World-Inio-Asano/dp/6555941197/ref=sr_1_1?
__mk_pt_BR=%C3%85M%C3%85%C5%BD%C3%95%C3%91&dchild=1&keywords=inio+asano&qid=1628810938&sr=8-1'
headers = {"user-agent":'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML,
like Gecko) Chrome/92.0.4515.131 Safari/537.36'}
def check_price():
page = requests.get(URL, headers= headers)
soup = BeautifulSoup(page.content, 'html.parser')
title= soup.find(id="productTitle").get_text()
price = soup.find(id ="price").get_text()
converted_price = float(price[0:2])
I get the error saying that the title and the price are nontype objects. How do I solve this problem?
Output: