一个小玩意,回头改善。

1 用 tk 封装一下

2 用户可以自己输入图片url

download_douban_album
 1 # -*-coding:UTF-8 -*-
 2 
 3 import re
 4 import urllib
 5 
 6 def count_percent(a, b, c):
 7     per = 100.0 * a * b / c
 8     if per > 100:
 9         per = 100
10     print '%.2f%%' % per
11 
12 
13 def get_url():
14     n = [x*18 for x in range(0, 87)]
15     url_list = []
16     for i in n:
17         url = 'http://www.douban.com/photos/album/73174384/?start=%s' % i
18         url_list.append(url)
19 
20     return url_list
21 
22 def get_img_url():
23     img_url = []
24     url = get_url()
25 
26     for u in url:
27         a = urllib.urlopen(u)
28         for line in a.readlines():
29             if 'thumb' in line:
30                 img_url.append(line.strip()[10:-4].replace('thumb', 'photo'))
31                 
32     return img_url
33 
34 def download_img():
35     download_url = get_img_url()
36 
37     for u in download_url:
38         urllib.urlretrieve(u, 'd:\\New\\%s' % u.split('/')[-1])
39     
40 
41 if __name__ == '__main__':
42     """a = get_img_url()
43     f = open('d:\\thumb.txt', 'w')
44     for i in a:
45         #j = i.replace('thumb', 'photo')
46         f.write(i+'\n')
47     f.close()"""
48     download_img()
posted on 2012-08-12 19:03  oyzway  阅读(1036)  评论(0编辑  收藏  举报