I want to get the product title from an amazon url-https://www.amazon.in/BATA-Fenny-Sneakers-7-India-8219990/dp/B07P8PMS25/ref=asc_df_B07P8PMS25/?tag=googleshopdes-21&linkCode=df0&hvadid=397006879402&hvpos=&hvnetw=g&hvrand=2284563689588211961&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=1007824&hvtargid=pla-837374864561&psc=1&ext_vrnc=hi. I tried this code
from bs4 import *
import requests
head={'user-agent':'betbargain/android-7.0/0.0.5'}
amaurl=input('Enter amazon url')
amazinfo=requests.get(amaurl,headers=head)
amasoup=BeautifulSoup(amazinfo.text,'lxml')
amatit=amasoup.find("span", attrs={"id":'productTitle'}).string.strip()
print(amatit)
But when I input the url it says-
Traceback (most recent call last):
File "c:/Users/rauna/Desktop/bb.py", line 7, in <module>
amatit=amasoup.find("span", attrs={"id":'productTitle'}).string.strip()
AttributeError: 'NoneType' object has no attribute 'string'
I have no idea why this has happened. Please tell me where I am wrong. Thanks in advance.