urlopen和urlretrieve

 1 import urllib
 2 import re
 3 
 4 url = "https://www.duitang.com/search/?kw=%E9%AC%BC%E6%80%AA&type=feed"
 5 page = urllib.urlopen(url)
 6 html = page.read()
 7 
 8 imglist = re.findall(r'src="(.*?\.(jpg|jpeg))"',html)
 9 
10 x=0
11 
12 for imgurl in imglist:
13     urllib.urlretrieve(imgurl[0],'/home/zl20163297/test/pachong/pics/guiguai/%d.jpg'%x)
14     x+=1
posted @ 2018-03-22 15:57  wydxry  阅读(197)  评论(0编辑  收藏  举报
Live2D