欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python批量下載壁紙的實(shí)現(xiàn)代碼

 更新時(shí)間:2012年08月06日 15:18:29   作者:  
壁紙來自桌酷網(wǎng)站,所有權(quán)歸屬其網(wǎng)站,本代碼僅做為交流學(xué)習(xí)使用,請(qǐng)勿用于商業(yè)用途,否則后果自負(fù)
復(fù)制代碼 代碼如下:

#! /usr/bin/env python

##python2.7-批量下載壁紙
##壁紙來自桌酷網(wǎng)站,所有權(quán)歸屬其網(wǎng)站
##本代碼僅做為交流學(xué)習(xí)使用,請(qǐng)勿用于商業(yè)用途,否則后果自負(fù)
##Code by Dreamlikes

import re,urllib,urllib2

#保存圖片的路徑
savepath = 'd:\\picture\\'

#壁紙集合的URL,如下
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."

相關(guān)文章

最新評(píng)論