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中的is和id用法分析
Jan 26 Python
python urllib爬取百度云连接的实例代码
Jun 19 Python
Python实现动态加载模块、类、函数的方法分析
Jul 18 Python
Python 中 Virtualenv 和 pip 的简单用法详解
Aug 18 Python
python使用Pycharm创建一个Django项目
Mar 05 Python
Python补齐字符串长度的实例
Nov 15 Python
Python实现通过解析域名获取ip地址的方法分析
May 17 Python
Django 解决model 反向引用中的related_name问题
May 19 Python
django为Form生成的label标签添加class方式
May 20 Python
Python爬虫实现百度翻译功能过程详解
May 29 Python
解决Pycharm双击图标启动不了的问题(JetBrains全家桶通用)
Aug 07 Python
浅谈Python numpy创建空数组的问题
May 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
php对二维数组按指定键值key排序示例代码
2013/11/26 PHP
php使用curl发送json格式数据实例
2013/12/17 PHP
PHP类和对象相关系统函数与运算符小结
2016/09/28 PHP
thinkphp5 加载静态资源路径与常量的方法
2017/12/24 PHP
Laravel框架运行出错提示RuntimeException No application encryption key has been specified.解决方法
2019/04/02 PHP
vmware linux系统安装最新的php7图解
2019/04/14 PHP
javascript 字符串连接的性能问题(多浏览器)
2008/11/18 Javascript
LazyForm jQuery plugin 定制您的CheckBox Radio和Select
2009/10/24 Javascript
Jquery实现三层遍历删除功能代码
2013/04/23 Javascript
javascript面向对象之this关键词用法分析
2015/01/13 Javascript
jQuery+PHP星级评分实现方法
2015/10/02 Javascript
微信小程序中单位rpx和rem的使用
2016/12/06 Javascript
微信小程序之仿微信漂流瓶实例
2016/12/09 Javascript
node.js请求HTTPS报错:UNABLE_TO_VERIFY_LEAF_SIGNATURE\的解决方法
2016/12/18 Javascript
Bootstrap模态框使用详解
2017/02/15 Javascript
在bootstrap中实现轮播图实例代码
2017/06/11 Javascript
Vue 监听列表item渲染事件方法
2018/09/06 Javascript
Vue 中文本内容超出规定行数后展开收起的处理的实现方法
2019/04/28 Javascript
js实现随机8位验证码
2020/07/24 Javascript
Webpack 4如何动态切割JS注入文件名详解
2019/07/09 Javascript
Python 错误和异常小结
2013/10/09 Python
python之import机制详解
2014/07/03 Python
python自动化测试实例解析
2014/09/28 Python
使用python语言,比较两个字符串是否相同的实例
2018/06/29 Python
查找python项目依赖并生成requirements.txt的方法
2018/07/10 Python
Sanic框架安装与简单入门示例
2018/07/16 Python
在PyCharm中三步完成PyPy解释器的配置的方法
2018/10/29 Python
python 采用paramiko 远程执行命令及报错解决
2019/10/21 Python
Matplotlib绘制雷达图和三维图的示例代码
2020/01/07 Python
Python实现井字棋小游戏
2020/03/09 Python
使用python把xmind转换成excel测试用例的实现代码
2020/10/12 Python
Python self用法详解
2020/11/28 Python
Canvas 文字碰撞检测并抽稀的方法
2019/05/27 HTML / CSS
英文翻译的自我评价语句
2013/10/04 职场文书
工地例会施工汇报材料
2014/08/22 职场文书
作文之亲情600字
2019/09/23 职场文书