我该如何解决这个错误?
代码
def sv():
url = url2
resp=requests.get(url)
if resp.status_code==200:
print("Managed to connect to the website.")
print("Info :-\n")
soup=BeautifulSoup(resp.text,'html.parser')
l=soup.find("h2",{"class":"etikett bottom-spacing-medium"})
for i in l.findAll("a"):
print(i.text)
else:
print("Error")
sv()
错误
Traceback (most recent call last):
File "c:\Users\----\Desktop\Python\Biler.py", line 41, in <module>
sv()
File "c:\Users\----\Desktop\Python\Biler.py", line 36, in sv
for i in l.findAll("a"):
AttributeError: 'NoneType' object has no attribute 'findAll'
问题
我已经被这个错误困住了一段时间。任何人都知道如何修复错误。