My problem is that i keep getting this error "AttributeError: 'NoneType' object has no attribute 'get_text'"
Can someone please explain what can I do to fix this type of error. Thanks
This is using python and BeautifulSoup inside jupiternb
URL = 'https://www.amazon.com/Funny-Data-Systems-Business-Analyst/dp/B07FNW9FGJ/ref=sr_1_3?dchild=1&keywords=data%2Banalyst%2Btshirt&qid=1626655184&sr=8'
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"}
page = requests.get(URL, headers=headers)
soup1 = BeautifulSoup(page.content, "html.parser")
soup2 = BeautifulSoup(soup1.prettify(), "html.parser")
title = soup2.find(id='title').get_text()
print(title)
Results:
AttributeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_1944\3978847060.py in <module>
11 soup2 = BeautifulSoup(soup1.prettify(), "html.parser")
12
---> 13 title = soup2.find(id='title').get_text()
14
15 print(title)
AttributeError: 'NoneType' object has no attribute 'get_text'