|
本帖最后由 1109065747 于 2018-3-22 19:58 编辑
1、#打印出符合条件的a标签html代码for a_content in soup.find('div',{'class':"dw_table"}).find_all('div',{'class':"el"}):
print(a_content.find('span').find('a'))
2、#打印出符合条件的a标签内容
for a_content in soup.find('div',{'class':"dw_table"}).find_all('div',{'class':"el"}):
print(a_content.find('span').find('a').get_text())
1段正确输出,2段报错AttributeError: 'NoneType' object has no attribute 'get_text',请问既然已经获取了符合条件的a标签为什么get_text()报错呢??
|
|