#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on Oct 29, 2016
@author: xwang
'''
import urllib2
import urllib
import re
urls = ["http://web.breadtrip.com/trips/2388032662/", ...]
rex = '"http://photos.breadtrip.com/.*imageView/2/w/960/q/85" target="_blank"'
def pachong():
y = 0
for url in urls:
up = urllib2.urlopen(url)
cont = up.read()
imgre = re.compile(rex)
imglist = re.findall(imgre,cont)
x = 0
y = y + 1
z = url[-7:-1]
for imgurl in imglist:
print imgurl[1:-17],x
urllib.urlretrieve(imgurl[1:-17],'C://Users//Administrator//Desktop//123//s_%s%s%s.jpg' % (x,y,z))
x = x + 1
if __name__=='__main__':
pachong()
网友评论