python BeautifulSoup的使用出错

作小寒 作小寒 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
__author__ = 'zy'
import re
import urllib
from BeautifulSoup import *
def get_content(url):
""".doc"""
html=urllib.urlopen(url)
content=html.read()
html.close()

return content


def get_images(info):
soup=BeautifulSoup(info)

all_img=soup.find_all('img',class_="BDE_Image")

x=1

for img in all_img:
image_name='%s.jpg' % x
urllib.urlretrieve(img['src'],image_name)
print img['src']
x+=1

info=get_content("https://tieba.baidu.com/p/4803144798?red_tag=1205304620")

print get_images(info)





输出执行后

Traceback (most recent call last):
File "C:\Users\zy\Desktop\py\soup.py", line 29, in <module>
print get_images(info)
File "C:\Users\zy\Desktop\py\soup.py", line 17, in get_images
all_img=soup.find_all('img',class_="BDE_Image")
TypeError: 'NoneType' object is not callable
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
作小寒
脚本语言 37,738 成员 34,208 内容