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批量修改文件名的实现代码
Sep 01 Python
Python网络爬虫实例讲解
Apr 28 Python
python 根据正则表达式提取指定的内容实例详解
Dec 04 Python
基于hashlib模块--加密(详解)
Jun 21 Python
python+pandas分析nginx日志的实例
Apr 28 Python
利用python循环创建多个文件的方法
Oct 25 Python
如何在Django中设置定时任务的方法示例
Jan 18 Python
PyQt5固定窗口大小的方法
Jun 18 Python
python利用tkinter实现屏保
Jul 30 Python
详解Python打包分发工具setuptools
Aug 05 Python
python使用gdal对shp读取,新建和更新的实例
Mar 10 Python
python3 使用openpyxl将mysql数据写入xlsx的操作
May 15 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中生成随机密码的自定义函数代码
2013/10/21 PHP
PHP培训要多少钱
2017/06/06 PHP
详解php语言最牛掰的Laravel框架
2017/11/20 PHP
one.php 多项目、函数库、类库 统一为一个版本的方法
2020/08/24 PHP
PHP 裁剪图片
2021/03/09 PHP
JavaScript 应用类库代码
2008/06/02 Javascript
修复IE9&safari 的sort方法
2011/10/21 Javascript
在jQuery中 关于json空对象筛选替换
2013/04/15 Javascript
jQuery选择器源码解读(一):Sizzle方法
2015/03/31 Javascript
kindeditor修复会替换script内容的问题
2015/04/03 Javascript
JavaScript合并两个数组并去除重复项的方法
2015/06/13 Javascript
javascript中使用new与不使用实例化对象的区别
2015/06/22 Javascript
纯jquery实现模仿淘宝购物车结算
2015/08/20 Javascript
JavaScript中的boolean布尔值使用学习及相关技巧讲解
2016/05/26 Javascript
js图片切换具体实现代码
2016/10/13 Javascript
jQuery Checkbox 全选 反选的简单实例
2016/11/29 Javascript
node.js基于mongodb的搜索分页示例
2017/01/22 Javascript
vue.js项目打包上线的图文教程
2017/11/16 Javascript
javaScript canvas实现(画笔大小 颜色 橡皮的实例)
2017/11/28 Javascript
小程序获取当前位置加搜索附近热门小区及商区的方法
2019/04/08 Javascript
[47:38]Optic vs VGJ.S 2018国际邀请赛小组赛BO2 第二场 8.17
2018/08/20 DOTA
Python中random模块用法实例分析
2015/05/19 Python
Python找出9个连续的空闲端口
2016/02/01 Python
Python基于回溯法子集树模板实现8皇后问题
2017/09/01 Python
python中scikit-learn机器代码实例
2018/08/05 Python
Python程序包的构建和发布过程示例详解
2019/06/09 Python
意大利奢侈品网站:Italist
2016/08/23 全球购物
俄罗斯的精英皮具:Wittchen
2018/01/29 全球购物
运动会广播稿400字
2014/01/25 职场文书
服装店营销方案
2014/03/10 职场文书
幼儿园教师岗位职责
2014/03/17 职场文书
个人安全生产责任书
2014/07/28 职场文书
运动会广播稿20字
2015/08/19 职场文书
2016年母亲节寄语
2015/12/04 职场文书
银行工作心得体会范文
2016/01/23 职场文书
《围炉夜话》110句人生箴言,精辟有内涵,引人深思
2019/10/23 职场文书