#coding:utf-8
import urllib
import re
def gethtml(url):
res=urllib.urlopen(url)
html=res.read()
return html
def getimg(html):
r1=r'src="(.*/*\.gif)"' #原来正则表达式中的括号表示最终匹配的是括号中的内容,丢掉src=" 和"这些内容
imgre=re.compile(r1)
imglist=re.findall(imgre,html)
for imgurl in imglist:
print "http://www.oschina.net"+imgurl
html1=gethtml("http://www.oschina.net/code/snippet_1015797_33632")
getimg(html1)
很简单的代码,继续修改中
参考自此处:
http://www.oschina.net/code/snippet_1015797_33632