Copy Code code as follows:
#! /usr/bin/env python
# #python2.7-Bulk Download Wallpaper
# #壁纸来自桌酷网站, ownership belongs to its website
# #本代码仅做为交流学习使用, do not use for commercial purposes, otherwise the consequences of the ego
# #Code by Dreamlikes
Import Re,urllib,urllib2
#保存图片的路径
Savepath = ' d:\\picture\\ '
#壁纸集合的URL, as follows
url = ' http://www.zhuoku.com/zhuomianbizhi/game-gamewall/20120503162540.htm '
Urlsource = Urllib.urlopen (URL). Read ()
Pattern = Re.compile (R ' <a href= "(\d+\ (\d+\) \.htm)", Re. M | Re. S
Match = Pattern.findall (Urlsource)
If match:
For Suburl in match:
Suburlsource = Urllib.urlopen (Url[0:url.rfind ('/') +1]+suburl). Read ()
Spattern = Re.compile (R ' var thunder_url = "(. *)"; ")
Picurl = Spattern.findall (Suburlsource) [0]
Getpic = Urllib2. Request (Picurl)
Getpic.add_header (' Referer ', ' http://www.zhuoku.com ')
f = open (Savepath+picurl[picurl.rfind ('/') + 1:], ' WB ')
F.write (Urllib2.urlopen (getpic). Read ())
F.close ()
Print "All done."