0
I’m trying to get the title of a product on the Amazon website, but the value returned is always None.
tag: <span id="producTitle" class="a-size-large product-title-word-break">
My code:
import requests
from bs4 import BeautifulSoup
URL = 'https://www.amazon.com.br/Câmera-Sony-Alpha-a7III-Mirrorless/dp/B07B43WPVK/ref=sr_1_1?__mk_pt_BR=ÅMÅŽÕÑ&dchild=1&keywords=sony+alpha+ilce-7m3&qid=1599604773&sr=8-1'
headers = {
"User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.135 Safari/537.36 OPR/70.0.3728.154'}
page = requests.get(URL, headers=headers)
soup = BeautifulSoup(page.content, 'html.parser')
title = soup.find(id="productTitle")
print(title)
The return:
None
Process finished with exit code 0
If you check the
status_code
answer will see that it returns a 503 error. Your problem is not with Beautifulsoup, you are making the wrong request. (see working here)– fernandosavio