代码如下:
# -*- coding: utf-8 -*-
import re
import urllib
def getHtml(url):
#找出给出网页的源码
page = urllib.urlopen(url)
html = page.read()
return html
def getImg(html):
#正则
reg = r'src="(.*?\.jpg)"'
#编译正则
imgre = re测试数据pile(reg)
#找出图片地址
imglist = re.findall(imgre,html)
#循环遍历
x = 0
for i in imglist:
urllib.urlretrieve(i,'%s.jpg' % x)
x+=1
html = getHtml(r'http://HdhCmsTestrenren测试数据/')
getImg(html)
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did87476