fun下载内容批量收集
2024-09-03 03:01:53
1.download title and url
#!/usr/bin/env python
#-*- coding:utf-8 -*- import re, urllib2,threading def geturltitle(match, file):
s = match.group();
p = re.compile(r'^\[mukio=file\]');
downurl = re.sub(p, '', s); print downurl;
# 过滤url
if downurl:
file.writelines(downurl);
file.write('\n');
# for line in downurl:
# file.write(line); # 过滤title
pattern1 = re.compile(r'<meta name="keywords" content="\S.*"');
match1 = pattern1.search(respread);
if match1:
s1 = match1.group();
p1 = re.compile(r'^<meta name="keywords" content="');
title = re.sub(p1, '', s1);
print title;
if title:
file.writelines(title);
file.write('\n\n');
# for line in title:
# file.write(line); while 1:
file = open('avfun1.txt', 'w');
for n in range(3600,9000):
try:
resp = urllib2.urlopen('http://www.avfun1.com/forum.php?mod=viewthread&tid='+repr(n)+'&mobile=yes', timeout = 2);
respread = resp.read();
pattern = re.compile(r'\[mukio=file\]\S.*mp4');
match = pattern.search(respread);
print "pid = " + repr(n) if match:
threading.Thread(target=geturltitle(match, file)).start();
# else:
# continue;
pass
except Exception, e:
print e;
pass
else:
pass
finally:
pass
file.close();
break;
2.rename title from file
#!/usr/bin/env python
#-*- coding:utf-8 -*- import re, os dir = "/Users/apple/Downloads/avfun1/" #文件目录 if os.path.isdir(dir): #检验目录是否有误
print ("Directory exists!")
else:
print ("Directory not exist.") filelist=os.listdir(dir+'aaa') file = open(dir+'avfun1.txt', 'rb'); dir = dir + 'aaa' '''for line in file:
print line
'''
str = file.read() for name in filelist:
match = re.search(name+r'\n\S.*', str) if match:
str1 = match.group();
tt_match = re.search(r'[^\d.mp4\n].*$', str1) newfile = tt_match.group()+'.mp4' #获取匹配名存为newfile
print name
print newfile
os.rename(os.path.join(dir,name),os.path.join(dir,newfile))
else:
print match
最新文章
- R笔记 单样本t检验 功效分析
- dotNet使用HttpWebRequest模拟浏览器
- 最小/大费用最大流模板(codevs1914)
- PYTHON 迭代器
- 【linux】英文显示乱码解决
- poj 1141 区间dp+递归打印路径
- [golang]反射的用处--代码自动生成
- jQuery基础 - 改变CSS样式
- QT 字符串相等间距字符间增加字符
- 01.C语言关于结构体的学习笔记
- hive-初看hive
- java jvm学习笔记五(实践自己写的类装载器)
- jaspersoft 5.6.0 相关问题
- .NET Core TDD 前传: 编写易于测试的代码 -- 单一职责
- DirectX11--HR宏关于dxerr库的替代方案
- 使用smb映射到本地时 访问权限,请联系管理员错误
- APP压力稳定性测试之monkey环境搭建
- kettle的下载、安装和初步使用(windows平台下)(图文详解)
- 前端性能优化 —— 减少HTTP请求
- 记录ssh暴力破解的密码字典