2 qq 34735655 qq_34735655 于 2016.09.11 14:58 提问

python beautifulsoup find函数连用出错

import urllib2
from bs4 import BeautifulSoup
from urllib import urlretrieve

url="https://www.pythonscraping.com"
c=urllib2.urlopen(url)
soup=BeautifulSoup(c,'html.parser')
link=soup.find('a',{'id':'logo'}).find("img")

显示
Traceback (most recent call last):
File "G:/helloworld/test.py", line 9, in
link=soup.find('a',{'id':'logo'}).find("img")
AttributeError: 'NoneType' object has no attribute 'find'
不明白为什么,上网也没有找到答案,望大家帮助

1个回答

dabocaiqq
dabocaiqq   2016.11.07 18:21
Csdn user default icon
上传中...
上传图片
插入图片