python批量下载壁纸的实现代码
网络编程
#! /usr/bin/env python
##python2.7-批量下载壁纸
##壁纸来自桌酷网站,所有权归属其网站
##本代码仅做为交流学习使用,请勿用于商业用途,否则后果自负
##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."
perl的格式化(Format)报表输出实现代码
perl有最好的文本数据处理能力.这是大家都知道的.在perl本身有一个别的软件没有的小功能,就是Perl格式.它相当于简单的命令行报表和图表输出.这个需
用Perl操作Excel文档的实例代码
在Linux或者Unix上操作(生成)Excel,CPAN上提供了Spreadsheet::WriteExcel和Spreadsheet::ParseExcel这两个模块。下面就来看看Spreadsheet::WriteExcel和Spreadsheet::ParseExcel
perl 删除数组元素的几种方法小结
1.用grep函数函数名grep调用语法@foundlist=grep(pattern,@searchlist);解说与同名的UNIX查找工具类似,grep函数在列表中抽取与指定模式匹配的元素,参数pattern为欲
标签:函数,壁纸,代码,报表,这是