python 下载网页图片
#encoding=utf-8'''Created on Dec 7, 2011@author: cooler'''import urllib2import urllibimport osimagepath=["http://hdn.xnimg.cn/photos/hdn221/20110528/1145/tiny_QKbC_85482j019118.jpg"]def cd(path): try: os.mkdir(path) os.chdir(path) return 0 except: return 1#download imagesdef image_down(path,list_image): cd(path) if not list_image: print "no img" else: for image in list_image: try: urllib.urlretrieve(image,image.split('/')[-1]) #利用image.split('/')[-1]获得文件名 print "save : "+image+" success !" except: print "save : "+image+" failure and continue...."#调用图片下载函数image_down("C:/img",imagepath)