osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error getting data from website


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?