1,Python环境
2,下面直接编写代码
import urllib
import re
import time
def getHtml(url):
page = urllib.urlopen(url)
html = page.read()
html = html.decode('utf-8')
return html
def getImgUrl(html):
str_re = r'<img[^>]src[=\"\']+([^\"\'])[\"\'][^>]*>'
imgre = re.compile(str_re,re.I)
imglist = re.findall(imgre,html)
for i in imglist:
urllib.urlretrieve(i,'/mnt/test/'+str(time.time())+".jpg")
#last setup is invocation and test it
html = getHtml('http://xxx.xxx.xxx')
getImgUrl(html)