此Python小脚本为抓取此页面: 下的所有jpg图像
'''
Created on 2013-4-2
@author: Administrator
'''
import re
import urllib
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
def getImg(html):
reg = r'src="(.*?\.jpg)" width'
imgreg = re.compile(reg)
imglist = re.findall(imgreg, html)
x = 0
for imgurl in imglist:
urllib.urlretrieve(imgurl, '%s.jpg' % x)
x += 1
html = getHtml("")
getImg(html)
阅读(892) | 评论(0) | 转发(0) |