采集代码采集练习(六) python获得chrome扩展 微度新标签页 下的云壁纸 采集代码
改章节是一篇关于采集代码的帖子采集析分见 采集训练(五) php 得获chrome扩展 微度新签标页 下的云壁纸(主要是美女壁纸)
以下是用python 实现一样的能功。
python 版本 2.73
以下是代码:
import urllib2,json,os
dir = "D:\python\weidu\images\\"
jsonUrl = "http://hao.weidunewtab.com/cloudWallpaper/index.json";
req = urllib2.Request(jsonUrl)
request = urllib2.urlopen(req).read();
jsonData = json.loads(request)
for i in jsonData:
nums = ''
nums = jsonData
numList = nums.split('-')
imageDir = dir+i+'\\'
if not os.path.isdir(imageDir):
os.mkdir(imageDir)
for n in range(int(numList),int(numList)+1):
imageUrl = ''
imageUrl = 'http://hao.weidunewtab.com/cloudWallpaper/'+str(i)+'/'+str(n)+'.jpg'
imageRe = urllib2.Request(imageUrl)
imageData = urllib2.urlopen(imageRe).read()
imageName = imageDir+str(n)+'.jpg'
file_object = open(imageName, 'wb')
file_object.write(imageData)
file_object.close()
文章结束给大家分享下程序员的一些笑话语录: 那是习惯决定的,一直保持一个习惯是不好的!IE6的用户不习惯多标签,但是最终肯定还是得转到多标签的浏览器。历史(软件UI)的进步(改善)不是以个人意志(习惯)为转移的!
页:
[1]