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中super的用法实例
May 28 Python
详解Python中映射类型的内建函数和工厂函数
Aug 19 Python
python常用函数详解
Sep 13 Python
python去除字符串中的换行符
Oct 11 Python
Python中的defaultdict与__missing__()使用介绍
Feb 03 Python
Python语言检测模块langid和langdetect的使用实例
Feb 19 Python
解决Pyinstaller 打包exe文件 取消dos窗口(黑框框)的问题
Jun 21 Python
python读取word 中指定位置的表格及表格数据
Oct 23 Python
python中的split()函数和os.path.split()函数使用详解
Dec 21 Python
Python定义一个函数的方法
Jun 15 Python
python tqdm实现进度条的示例代码
Nov 10 Python
Python数据清洗工具之Numpy的基本操作
Apr 22 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
Apache, PHP在Windows 9x/NT下的安装与配置 (二)
2006/10/09 PHP
PHP实现提取一个图像文件并在浏览器上显示的代码
2012/10/06 PHP
codeigniter中测试通过的分页类示例
2014/04/17 PHP
php采用curl实现伪造IP来源的方法
2014/11/21 PHP
PHP实现的DES加密解密实例代码
2016/04/06 PHP
php基于协程实现异步的方法分析
2019/07/17 PHP
jquery表格内容筛选实现思路及代码
2013/04/16 Javascript
一个简单的全屏图片上下打开显示网页效果示例
2014/07/08 Javascript
酷! 不同风格页面布局幻灯片特效js实现
2021/02/19 Javascript
jQuery实现简易的输入框字数计数功能示例
2017/01/16 Javascript
自制简易打赏功能的实例
2017/09/02 Javascript
深入浅析Vue.js计算属性和侦听器
2018/05/05 Javascript
Vue中的vue-resource示例详解
2018/11/02 Javascript
JS三级联动代码格式实例详解
2019/12/30 Javascript
vue 出现data-v-xxx的原因及解决
2020/08/04 Javascript
Node.js 中判断一个文件是否存在
2020/08/24 Javascript
Python实现竖排打印传单手机号码易撕条
2015/03/16 Python
Python环境下搭建属于自己的pip源的教程
2016/05/05 Python
python中logging库的使用总结
2017/10/18 Python
pandas多级分组实现排序的方法
2018/04/20 Python
Python基于class()实现面向对象原理详解
2020/03/26 Python
碧欧泉美国官网:Biotherm美国
2016/08/31 全球购物
澳大利亚最大的女装零售商:Millers
2017/09/10 全球购物
西班牙在线光学:Visual-Click
2020/06/22 全球购物
MIKI HOUSE美国官方网上商店:日本领先的婴儿和儿童高级时装品牌
2020/06/21 全球购物
计算 s=(x*y)1/2,用两个宏定义来实现
2016/08/11 面试题
常见的软件开发流程有哪些
2015/11/14 面试题
岗位职责定义及内容
2013/11/08 职场文书
国贸类专业毕业生的求职信分享
2013/12/08 职场文书
建筑工程管理专业自荐信范文
2013/12/28 职场文书
将相和教学反思
2014/02/04 职场文书
租车协议书
2015/01/27 职场文书
保洁员岗位职责
2015/02/04 职场文书
理想国读书笔记
2015/06/25 职场文书
堂吉诃德读书笔记
2015/06/30 职场文书
2016入党积极分子党课培训心得体会
2016/01/06 职场文书