标签:html run findall decode 定义 port list import orm
import re
import urllib.request
class Picture(object):
def run(self):
# 定义变量url 获取要下载图片的地址
url = "http://www.txt100.com/bbrvtwyhknv/85774146.html"
response = urllib.request.urlopen(url).read().decode(‘utf-8‘)
imglist = re.findall(‘src="(.+?\.jpg)"‘, response)
x = 0
for imgurl in imglist:
imgurl = ‘http://www.txt100.com‘ + imgurl
urllib.request.urlretrieve(imgurl, "./{}.jpg".format(x))
x = x + 1
print("第", x, "张下载完毕")
if __name__ == ‘__main__‘:
p = Picture()
p.run()
标签:html run findall decode 定义 port list import orm
原文地址:https://www.cnblogs.com/victorstudy/p/11237287.html