有个网站图片很好看,网址也很有规律,但是有的是空链接。用python都下下来了。
import urllib def main(): url='http://static.host.com/wallpapers/picture-' path='/home/me/Pictures/wallpaper/picture-' for i in range(0,400): url=url+str(i)+".jpg" print url doc=urllib.urlopen(url) type=doc.info().getheader('Content-Type') if(type.find('jpeg')!=-1): path=path+str(i)+".jpg" data=urllib.urlopen(url).read() f=file(path,"wb") f.write(data) f.close() path='/home/me/Pictures/wallpaper/picture-' print str(i)+"OK" url='http://static.host.com/wallpapers/picture-' if __name__ == "__main__": main()
本文更新於 2014/05/26。