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

fun下载内容批量收集的更多相关文章

  1. 向linux服务器上传下载文件方式收集

    向linux服务器上传下载文件方式收集 1. scp [优点]简单方便,安全可靠:支持限速参数[缺点]不支持排除目录[用法] scp就是secure copy,是用来进行远程文件拷贝的.数据传输使用 ...

  2. (转)libcurl应用:如何把下载内容写入内存

    libcurl应用:如何把下载内容写入内存 2008-01-13 00:32:52|  分类: 默认分类 |举报 |字号 订阅   libcurl的文档中有 getinmemory.c这个例子,把下载 ...

  3. EasyUI form ajax submit到MVC后,在IE下提示下载内容的解决办法

    问题描述: 项目环境为,.Net Mvc5+EF6……前端框架使用的是EasyUI v1.4.4. 在视图页面中,使用form的submit方法提交表单数据时,如果是使用IE的话,请求成功后IE会提示 ...

  4. API例子:用Java/JavaScript下载内容提取器

    1,引言 本文讲解怎样用Java和JavaScript使用 GooSeeker API 接口下载内容提取器,这是一个示例程序.什么是内容提取器?为什么用这种方式?源自Python即时网络爬虫开源项目: ...

  5. chrome浏览器下载内容存放位置

    点击: 或者直接快捷键 ctrl +J 打开下载的资料在[设置]中可将浏览器设置成默认浏览器,更换下载内容的存放位置:给一个提示,本人未曾修改下载的存放位置,是用户/Administrator/Dow ...

  6. PDF文本内容批量提取到Excel

    QQ:231469242,版权所有 sklearn实战-乳腺癌细胞数据挖掘 https://study.163.com/course/introduction.htm?courseId=1005269 ...

  7. 2018-11-8-WPF-获取下载内容长度

    title author date CreateTime categories WPF 获取下载内容长度 lindexi 2018-11-08 20:18:15 +0800 2018-11-08 20 ...

  8. shell脚本批量收集linux服务器的硬件信息快速实现

    安装ansible批量管理系统.(没有的话,ssh远程命令循环也可以) 在常用的数据库里面新建一张表,用你要收集的信息作为列名,提供可以用shell插入.

  9. nodejs读取excel内容批量替换并生成新的html和新excel对照文件

    因为广告投放需要做一批对外投放下载页面,由于没有专门负责填充页面的编辑同学做,只能前端来做了, 拿到excel看了一下,需要生成200多个文件,一下子懵逼了. 这要是来回复制粘贴太low了 正好最新用 ...

随机推荐

  1. POJ - 3126 Prime Path 素数筛选+BFS

    Prime Path The ministers of the cabinet were quite upset by the message from the Chief of Security s ...

  2. ASP.NET Core Web API + Angular 仿B站(三)后台配置 JWT 的基于 token 的验证

    前言: 本系列文章主要为对所学 Angular 框架的一次微小的实践,对 b站页面作简单的模仿. 本系列文章主要参考资料: 微软文档: https://docs.microsoft.com/zh-cn ...

  3. Shader第十三讲 Alpha混合

    http://blog.sina.com.cn/s/blog_471132920101d8z5.html Alpha Blending,中文译作Alpha混合Blending就是控制透明的.处于光栅化 ...

  4. element-ui + el-dialog + Vue.component 注册的富文本控件 第二次及以后打开dialog出现问题解决方法

    自定控件 添加属性  v-if="dialogVisible" <el-dialog title="" :visible.sync="dialo ...

  5. 在项目中移除CocoaPods

    如果你觉得CocoaPods让你的项目出现了问题,不好用甚至是恶心,想将其从项目中彻底移除,也有方法: 1.删除工程文件夹下的Podfile.Podfile.lock和Pods文件夹. 2.删除xcw ...

  6. 转 载python数据分析(1)-numpy产生随机数

    转自:http://blog.csdn.net/jinxiaonian11/article/details/53143141 在数据分析中,数据的获取是第一步,numpy.random 模块提供了非常 ...

  7. asp.net多文件上传

    文件上传简单实现是非常容易的,但是想要更高的要求,比如通过ajax上传文件.一次上传多个文件.文件比较大等等,这里面的坑就不是很容易填(对于新手来说).因此在这里我准备通过ajax实现多文件上传.在开 ...

  8. 2个rman自动恢复的脚本

    ### scripts 1--the scirpt is used for restore db from vcs to a point to time recovery--and the targe ...

  9. freertos之内存管理

    任务.信号量.邮箱才调度器开始调度之前就应该创建,所以它不可能像裸奔程序那样的函数调用能确定需要多少内存资源,RTOS提供了3种内存管理的方法: 1 方法一:确定性好适合于任务.信号量.队列都不被删除 ...

  10. 左右两个Select列表框交换数据的JS

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD ...