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 01 Python
python的文件操作方法汇总
Nov 10 Python
python实现外卖信息管理系统
Jan 11 Python
python爬虫基础教程:requests库(二)代码实例
Apr 09 Python
为什么从Python 3.6开始字典有序并效率更高
Jul 15 Python
Django实现web端tailf日志文件功能及实例详解
Jul 28 Python
利用python list完成最简单的DB连接池方法
Aug 09 Python
Python使用py2neo操作图数据库neo4j的方法详解
Jan 13 Python
翻转数列python实现,求前n项和,并能输出整个数列的案例
May 03 Python
Vs Code中8个好用的python 扩展插件
Oct 12 Python
python中的random模块和相关函数详解
Apr 22 Python
python数据分析之单因素分析线性拟合及地理编码
Jun 25 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
非洲第一个咖啡超凡杯大赛承办国—卢旺达的咖啡怎么样
2021/03/03 咖啡文化
PHP设计聊天室步步通
2006/10/09 PHP
php实现excel中rank函数功能的方法
2015/01/20 PHP
PHP常见数组函数用法小结
2016/03/21 PHP
php版微信开发之接收消息,自动判断及回复相应消息的方法
2016/09/23 PHP
PHP+fiddler抓包采集微信文章阅读数点赞数的思路详解
2019/12/20 PHP
PHP 实现 WebSocket 协议原理与应用详解
2020/04/22 PHP
jquery下组织javascript代码(js函数化)
2010/08/25 Javascript
$.ajax返回的JSON无法执行success的解决方法
2011/09/09 Javascript
有关于eclipse配置spket需要注意的一些地方
2013/04/07 Javascript
js实现无需数据库的县级以上联动行政区域下拉控件
2013/08/14 Javascript
window.opener用法和用途实例介绍
2013/08/19 Javascript
javascript字符串替换及字符串分割示例代码
2013/12/12 Javascript
JS截取与分割字符串常用技巧总结
2015/11/10 Javascript
Json对象和字符串互相转换json数据拼接和JSON使用方式详细介绍(小结)
2016/10/25 Javascript
javascript实现圣旨卷轴展开效果(代码分享)
2017/03/23 Javascript
微信小程序页面传值实例分析
2017/04/19 Javascript
vue 组件的封装之基于axios的ajax请求方法
2018/08/11 Javascript
对vue v-if v-else-if v-else 的简单使用详解
2018/09/29 Javascript
JavaScript内置对象math,global功能与用法实例分析
2019/06/10 Javascript
vant-ui框架的一个bug(解决切换后onload不触发)
2020/11/11 Javascript
python调用虹软2.0第三版的具体使用
2019/02/22 Python
利用Python查看微信共同好友功能的实现代码
2019/04/24 Python
windows下python虚拟环境virtualenv安装和使用详解
2019/07/16 Python
Anaconda3中的Jupyter notebook添加目录插件的实现
2020/05/18 Python
存储过程的优点有哪些
2012/09/27 面试题
模具专业推荐信
2013/10/30 职场文书
企划专员岗位职责
2013/12/09 职场文书
教师应聘自荐信范文
2014/03/14 职场文书
校园活动策划方案
2014/06/13 职场文书
公司总经理岗位职责范本
2014/08/15 职场文书
2015应届毕业生自荐信范文
2015/03/05 职场文书
2015年党风廉政建设目标责任书
2015/05/08 职场文书
2016年学校安全教育月活动总结
2016/04/06 职场文书
Java实现房屋出租系统详解
2021/10/05 Java/Android
Win11怎么启动任务管理器?Win11启动任务管理器的几种方法
2021/11/23 数码科技