Python解析网页源代码中的115网盘链接实例


Posted in Python onSeptember 30, 2014

本文实例讲述了python解析网页源代码中的115网盘链接的方法。分享给大家供大家参考。具体方法分析如下:

其中的1.txt,是网页http://bbs.pediy.com/showthread.php?t=144788另存为1.txt

具体代码如下:

import re 
   
if __name__ == "__main__": 
  fp = open("c:\\1.txt") 
   
  https = re.compile(r"(http://u.*)") 
  for url in https.findall(fp.read()): 
    print url

输出结果:

http://u.115.com/file/f61cb107c8 
http://u.115.com/file/f6806f45b8 
http://u.115.com/file/f6ec42d4d3 
http://u.115.com/file/f6deb05ec4 
http://u.115.com/file/f6e51f6838 
http://u.115.com/file/f66edaf8d3  
http://u.115.com/file/f6d07e07b9 
http://u.115.com/file/f6d7f585a8 
http://u.115.com/file/f639d8b3cf 
http://u.115.com/file/f6dcadbde6 
http://u.115.com/file/f6ea3f01c1 
http://u.115.com/file/f65b96a06f  
http://u.115.com/file/f682da085a  
http://u.115.com/file/f6486e698 
http://u.115.com/file/f6b7491d9f 
http://u.115.com/file/f622b7f9a7 
http://u.115.com/file/f64e2424b9 
http://u.115.com/file/f6e5132d4d  
http://u.115.com/file/f655c10e86  
http://u.115.com/file/f6b22e64e6 
http://u.115.com/file/f6812126a4  
http://u.115.com/file/f6523e625c 
http://u.115.com/file/f63e0ccb28 
http://u.115.com/file/f611e07b8a# 
http://u.115.com/file/f6e047bccc#  
http://u.115.com/file/f6d348d781# 
http://u.115.com/file/f6ada24153# 
http://u.115.com/file/f64f97518b#  
http://u.115.com/file/f6f9ba96f8# 
http://u.115.com/file/f650e06f38# 
http://u.115.com/file/f683ee5b2a# 
http://u.115.com/file/f69009bfc2# 
http://u.115.com/file/f6ea427646# 
http://u.115.com/file/f6acdc6b7f# 
http://u.115.com/file/f6c85745d0# 
http://u.115.com/file/f61a26cf12# 
http://u.115.com/file/f631edf5c6#  
http://u.115.com/file/f6b0fa6fb8# 
http://u.115.com/file/f6f5fe8962# 
http://u.115.com/file/f6bf975e0#  
http://u.115.com/file/f6d522784c#  
http://u.115.com/file/f6b5ac9991#  
http://u.115.com/file/f62e80ced5#  
http://u.115.com/file/f6bff09c0c#  
http://u.115.com/file/f663fc4a54# 
http://u.115.com/file/blpk4pv1 
http://u.115.com/file/c4rjotdz 
http://u.115.com/file/f6a960aca8# 
http://u.115.com/file/efnn38jr 
http://u.115.com/file/c4leomjd 
http://u.115.com/file/dlpw9s6i 
http://u.115.com/file/f6d3cbebe0# 
http://u.115.com/file/f6de8062b2# 
http://u.115.com/file/ef8og8la 
http://u.115.com/file/f6f6391ac6# 
http://u.115.com/file/f628d256ae# 
http://u.115.com/file/f66a049dc9# 
http://u.115.com/file/f62bf1750a# 
http://u.115.com/file/f642e47260# 
http://u.115.com/file/f693eb7c89# 
http://u.115.com/file/f6ed68ba9b# 
http://u.115.com/file/f6f099c3f9# 
http://u.115.com/file/f61ac19339# 
http://u.115.com/file/f6f3c78d2c# 
http://u.115.com/file/f6696f6348# 
http://u.115.com/file/f6e88eeefb# 
http://u.115.com/file/f66471e4eb# 
http://u.115.com/file/f672da54ae# 
http://u.115.com/file/dnasw0kp# 
http://u.115.com/file/dnagnndx# 
http://u.115.com/file/clwr2xxg# 
http://u.115.com/file/bhbcnnwe# 
http://u.115.com/file/aq2rp9ga# 
http://u.115.com/file/e601turs# 
http://u.115.com/file/dn46qs7x# 
http://u.115.com/file/clwonrwg# 
http://u.115.com/file/dn43i7jf# 
http://u.115.com/file/bhbgrnfz# 
http://u.115.com/file/dnsl0kxp#

希望本文所述对大家的Python程序设计有所帮助

Python 相关文章推荐
在漏洞利用Python代码真的很爽
Aug 26 Python
一个基于flask的web应用诞生 组织结构调整(7)
Apr 11 Python
python查看列的唯一值方法
Jul 17 Python
python用pandas数据加载、存储与文件格式的实例
Dec 07 Python
linux环境下安装python虚拟环境及注意事项
Jan 07 Python
tf.concat中axis的含义与使用详解
Feb 07 Python
用python介绍4种常用的单链表翻转的方法小结
Feb 24 Python
Python可变对象与不可变对象原理解析
Feb 25 Python
使用Python将图片转正方形的两种方法实例代码详解
Apr 29 Python
什么是Python中的顺序表
Jun 02 Python
python爬虫中PhantomJS加载页面的实例方法
Nov 12 Python
Pycharm 设置默认解释器路径和编码格式的操作
Feb 05 Python
python网络编程之读取网站根目录实例
Sep 30 #Python
python中sets模块的用法实例
Sep 30 #Python
python根据路径导入模块的方法
Sep 30 #Python
python基于xml parse实现解析cdatasection数据
Sep 30 #Python
python中ConfigParse模块的用法
Sep 29 #Python
Python中logging模块的用法实例
Sep 29 #Python
Python基于twisted实现简单的web服务器
Sep 29 #Python
You might like
PHP实现UTF-8文件BOM自动检测与移除实例
2014/11/05 PHP
PHP中异常处理的一些方法整理
2015/07/03 PHP
详解PHP的Yii框架中自带的前端资源包的使用
2016/03/31 PHP
Laravel实现表单提交
2017/05/07 PHP
Yii2中简单的场景使用介绍
2017/06/02 PHP
PHP基于rabbitmq操作类的生产者和消费者功能示例
2018/06/16 PHP
Laravel如何实现适合Api的异常处理响应格式
2020/06/14 PHP
JavaScript初学者应注意的七个细节小结
2012/01/30 Javascript
当前页禁止复制粘贴截屏代码小集
2013/07/24 Javascript
jQuery动态显示和隐藏datagrid中的某一列的方法
2013/12/11 Javascript
js清除input中type等于file的值域(示例代码)
2013/12/24 Javascript
JavaScript实现判断图片是否加载完成的3种方法整理
2015/03/13 Javascript
jQuery查找节点方法完整实例
2016/09/13 Javascript
基于vue.js实现侧边菜单栏
2017/03/20 Javascript
详解webpack与SPA实践之开发环境搭建
2017/12/18 Javascript
Vue指令v-for遍历输出JavaScript数组及json对象的常见方式小结
2019/02/11 Javascript
ES6知识点整理之对象解构赋值应用示例
2019/04/17 Javascript
Vue表单提交点击事件只允许点击一次的实例
2020/10/23 Javascript
[01:10:03]OG vs EG 2018国际邀请赛淘汰赛BO3 第三场 8.23
2018/08/24 DOTA
Python3实现计算两个数组的交集算法示例
2019/04/03 Python
基于python实现高速视频传输程序
2019/05/05 Python
Python scrapy爬取小说代码案例详解
2020/07/09 Python
python 使用paramiko模块进行封装,远程操作linux主机的示例代码
2020/12/03 Python
在Python中实现字典反转案例
2020/12/05 Python
pytorch __init__、forward与__call__的用法小结
2021/02/27 Python
html5 移动端视频video的android兼容(去除播放控件、全屏)
2020/03/26 HTML / CSS
美国女孩洋娃娃店:American Girl
2017/10/24 全球购物
为什么在使用动态 SQL 语句时必须为低层数据库对象授予权限
2012/12/13 面试题
团队精神的演讲稿
2014/05/14 职场文书
英语分层教学实施方案
2014/06/15 职场文书
见习报告的格式
2014/10/31 职场文书
2014高三学生考试作弊检讨书
2014/12/14 职场文书
小兵张嘎观后感
2015/06/03 职场文书
适合青年人白手起家的创业项目分享
2019/08/16 职场文书
python pyhs2 的安装操作
2021/04/07 Python
AJAX实现指定部分页面刷新效果
2021/10/16 Javascript