import urllib.request
import re
url = 'https://movie.douban.com/top250'
request = urllib.request.Request(url)
request.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36')
response = urllib.request.urlopen(request)
buf = response.read()
buf = str(buf, encoding='utf-8')
//print(buf)
//获取所有图片url地址列表
listurl = re.findall(r'http.+\.jpg', buf)
print(listurl)
i = 1
for url in listurl:
f = open(str(i)+'.jpg', 'wb+')
req = urllib.request.urlopen(url)
buf = req.read()
# buf = str(buf)
f.write(buf)
i += 1
https://blog.csdn.net/qq_3781...
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。