Error getting data from website

Sam Paython spayth77 at gmail.com
Fri Dec 6 18:53:11 EST 2019


Hi all,

This is the code I am writing:

import requests
from bs4 import BeautifulSoup


request = requests.get("https://www.amazon.ca/dp/B07RZFQ6HC")
content = request.content
soup = BeautifulSoup(content, "html.parser")
element = soup.find("span",{"id":"priceblock_dealprice"})
print(element.text.strip())


and this is the error I am getting: 

C:\Users\Sam\PycharmProjects\untitled2\venv\Scripts\python.exe C:/Users/Sam/PycharmProjects/untitled2/src/app.py
Traceback (most recent call last):
  File "C:/Users/Sam/PycharmProjects/untitled2/src/app.py", line 9, in <module>
    print(element.text.strip())
AttributeError: 'NoneType' object has no attribute 'text'

Could someone please help?


More information about the Python-list mailing list