#!/usr/bin/python
import re
import urllib
#def getHtml(url):
# urllib.open(url)
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
def getImg(html):
reg = r'src="(.*?\.jpg)"'
imgre = re.compile(reg)
imglist = re.findall(imgre,html)
# return imglist
x = 1000
for imgurl in imglist:
urllib.urlretrieve(imgurl,'jpg/%s.jpg' % x)
x+=1
print imgurl
html = getHtml(" http://bbs.voc.com.cn/topic-5094572-1-1.html ")
getImg(html)
import re
import urllib
#def getHtml(url):
# urllib.open(url)
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
return html
def getImg(html):
reg = r'src="(.*?\.jpg)"'
imgre = re.compile(reg)
imglist = re.findall(imgre,html)
# return imglist
x = 1000
for imgurl in imglist:
urllib.urlretrieve(imgurl,'jpg/%s.jpg' % x)
x+=1
print imgurl
html = getHtml(" http://bbs.voc.com.cn/topic-5094572-1-1.html ")
getImg(html)
本文转自 jxwpx 51CTO博客,原文链接:http://blog.51cto.com/jxwpx/1177179,如需转载请自行联系原作者