__author__ = mkdir(path):
os
path = path.strip() path = path.rstrip() mkfile = os.path.exists(path)
mkfile:
()
:
os.makedirs(path)
()
urllib, urllib2, re
geturl(url):
file_lists = []
req = urllib2.Request(url)
req.add_header(,
)
data = urllib2.urlopen(req)
f = data.read()
img = re.compile(, re.S)
file_list = re.findall(img, f)
f_list file_list:
:
f_url = f_list.index()
f_url:
file_li = f_list[f_list.index():f_url + ]
file_lists.append(file_li)
e:
(e.message)
file_lists
save_file(path, url):
mkdir(path)
url_list = geturl(url)
url_i url_list:
req = urllib2.Request(url_i)
req.add_header(, )
data = urllib2.urlopen(req)
data_picture = data.read()
path_pic = path + + url_i[-:]
(path_pic, ) f:
f.write(data_picture)
f.flush()
__name__ == :
path = url = save_file(path, url)