获取分享社最新一期的迅雷分享账号
2015-07-27 01:11
513 查看
#coding:utf-8 import urllib2 import re import time import datetime print time.strftime('当前时间是:%Y年%m月%d日 %H:%M:%S',time.localtime(time.time())).decode('utf-8') t = datetime.datetime.now() month = t.month day = t.day url_home = 'http://www.fenxs.com/' patt = 'www\.fenxs\.com\/\d+\.html" \S+ ' + str(month) + '\S\S\S' + str(day) + '\S\S\S' # www.fenxs.com/1540.html" title="分享社 7月15日 try: html_home = urllib2.urlopen(url_home,timeout=10).read() except urllib2.URLError,e: print(e.reason) search_url = re.search(patt,html_home) print(u'正在查找资源...') if search_url: print(u'找到资源...') else: print(u'没有找到资源...') resource_url = 'http://' + str( re.match(('www\.fenxs\.com\/\d+\.html'),search_url.group()).group() ) print(u'资源链接:%s' % resource_url) try: html_resource = urllib2.urlopen(resource_url,timeout=10).read() except urllib2.URLError,e: print(e.reason) patt_resource = '[\\x80-\\xff]+\w{6,}:[12][\\x80-\\xff]+\w+<' search_account_resource = re.findall(patt_resource,html_resource) if t.month<10: _time = str(t.year)+'0'+str(t.month) else: _time = str(t.year)+str(t.month) if t.day<10: _time = _time+'0'+str(t.day) else: _time = _time+str(t.day) file_name = 'xunlei_'+_time+'.txt' account_resource = open(file_name,'w') for i in search_account_resource: print(i[:-1].decode('utf-8')) account_resource.write(i[:-1]+'\n') account_resource.close() print(u'账号已生成在本目录下的%s文件中...' % file_name)
稍微修改了一下:http://bbs.fishc.com/thread-57687-1-1.html
相关文章推荐
- Python动态类型的学习---引用的理解
- Python3写爬虫(四)多线程实现数据爬取
- 垃圾邮件过滤器 python简单实现
- 下载并遍历 names.txt 文件,输出长度最长的回文人名。
- install and upgrade scrapy
- Scrapy的架构介绍
- Centos6 编译安装Python
- 使用Python生成Excel格式的图片
- 让Python文件也可以当bat文件运行
- [Python]推算数独
- Python中zip()函数用法举例
- Python中map()函数浅析
- Python在CAM软件Genesis2000中的应用
- 使用Shiboken为C++和Qt库创建Python绑定
- FREEBASIC 编译可被python调用的dll函数示例
- Python 七步捉虫法
- Python实现的基于ADB的Android远程工具