# -*- 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="http://www.kaotop.com/skin/sinaskin/image/nopic.gif"'
#编译正则
imgre = re.compile(reg)
#找出图片地址
imglist = re.findall(imgre,html)
#循环遍历
x = 0
for i in imglist:
urllib.urlretrieve(i,'%s.jpg' % x)
x+=1
html = getHtml(r'http://www.renren.com/')
getImg(html)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)