下载图片
下载图片
#! /usr/bin/env python #coding=utf-8 import re import urllib2 import urllib,os def download(url): pattern='"objURL":"http://.{20,120}.jpg\s+"' res=urllib2.urlopen(url) content=res.read() del res foundlist=re.findall(pattern,content) for i in range(len(foundlist)): name=str(i)+".jpg" urllib.(eval(foundlist[i][9:]),os.path.join(r"c:\temp",name)) if __name__=="__main__": url="http://image.baidu.com/i?ct=201326592&cl=2&lm=-1&tn=baiduimage&pv=&z=0&word=%C1%F5%B5%C2%BB%AA&s=0" download(url)