简单的抓取网页中的图片

来源:互联网 发布:小学英语课文朗读软件 编辑:程序博客网 时间:2024/05/19 02:24
#coding:utf-8import urllibimport redef gethtml(url):    res=urllib.urlopen(url)    html=res.read()    return htmldef 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"+imgurlhtml1=gethtml("http://www.oschina.net/code/snippet_1015797_33632")getimg(html1)

很简单的代码,继续修改中


参考自此处:

http://www.oschina.net/code/snippet_1015797_33632

0 0
原创粉丝点击