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中的pydoc模块和distutils模块
Apr 13 Python
详解Python读取配置文件模块ConfigParser
May 11 Python
Python字符编码与函数的基本使用方法
Sep 30 Python
Python三种遍历文件目录的方法实例代码
Jan 19 Python
python生成带有表格的图片实例
Feb 03 Python
手把手教你使用Python创建微信机器人
Apr 29 Python
Django中ORM外键和表的关系详解
May 20 Python
Python中模块(Module)和包(Package)的区别详解
Aug 07 Python
python进程的状态、创建及使用方法详解
Dec 06 Python
Python高阶函数、常用内置函数用法实例分析
Dec 26 Python
pytorch中 gpu与gpu、gpu与cpu 在load时相互转化操作
May 25 Python
OpenCV绘制圆端矩形的示例代码
Aug 30 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中将html中的br换行符转换为文本输入中的换行符
2013/03/26 PHP
PHP实现简单计算器小程序
2020/08/28 PHP
javascritp实现input输入框相关限制用法
2007/06/29 Javascript
doctype后如何获得body.clientHeight的方法
2007/07/11 Javascript
jQuery对象和DOM对象相互转化
2009/04/24 Javascript
javascript中的prototype属性实例分析说明
2010/08/09 Javascript
获取客户端网卡MAC地址和IP地址实现JS代码
2013/03/17 Javascript
IE6已终止操作问题的2种情况及解决
2014/04/23 Javascript
Javascript数组与字典用法分析
2014/12/13 Javascript
老生常谈 关于JavaScript的类的继承
2016/06/24 Javascript
JavaScript基础重点(必看)
2016/07/09 Javascript
jQuery progressbar通过Ajax请求实现后台进度实时功能
2016/10/11 Javascript
JS作用域深度解析
2016/12/29 Javascript
Vue 实用分页paging实例代码
2017/04/12 Javascript
AngularJS基于provider实现全局变量的读取和赋值方法
2017/06/28 Javascript
javascript基于定时器实现进度条功能实例
2017/10/13 Javascript
vue中前进刷新、后退缓存用户浏览数据和浏览位置的实例讲解
2018/09/21 Javascript
基于Koa2写个脚手架模拟接口服务的方法
2018/11/27 Javascript
JS数组方法shift()、unshift()用法实例分析
2020/01/18 Javascript
如何通过Proxy实现JSBridge模块化封装
2020/10/22 Javascript
vue实现点击出现操作弹出框的示例
2020/11/05 Javascript
[03:02]生活中的Dendi之野外度假篇
2016/08/09 DOTA
python 算法 排序实现快速排序
2012/06/05 Python
跟老齐学Python之Python安装
2014/09/12 Python
详解字典树Trie结构及其Python代码实现
2016/06/03 Python
python实现输入数字的连续加减方法
2018/06/22 Python
python实现海螺图片的方法示例
2019/05/12 Python
解决python文件双击运行秒退的问题
2019/06/24 Python
python3中关于excel追加写入格式被覆盖问题(实例代码)
2020/01/10 Python
python 如何调用 dubbo 接口
2020/09/24 Python
详解Python调用系统命令的六种方法
2021/01/28 Python
中国跨境在线时尚零售商:Bellelily
2018/04/06 全球购物
Lookfantastic日本官网:英国知名护肤、化妆品和头发护理购物网站
2018/04/21 全球购物
俄罗斯一家时尚女装商店:Charuel
2019/12/04 全球购物
给国外客户的邀请函
2014/01/30 职场文书
安全生产感想
2015/08/07 职场文书