一、环境

Windows 10、PyCharm 社区版本、Python3.5

二、参考

Python爬虫爬取网页图片(坑)

Python爬取图片1——简单爬取图片(踩坑)

本来参考这个教程,没想到Python3不能使用python2 的库,有很多地方需要修改:

参考:Python基础学习-'module' object has no attribute 'urlopen'解决方法 主要是库不同以及编码不同进行修改

“AttributeError: 'module' object has no attribute 'urlopen'”

TypeError: can't use a string pattern on a bytes-like object

修改之后,依旧无法运行,只能对返回的内容print()查看

1、print(html)发现正确

2、print(imglist)发现空值

此时应该是reg = r'src="(.+?\.jpg)" pic_ext'这个正则表达有问题,继续百度ing

三、建议参考教程

Python爬虫入门——爬取贴吧图片

相关文章: