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使用webbrowser浏览指定url的方法
Apr 04 Python
Python中的字符串查找操作方法总结
Jun 27 Python
Python常见工厂函数用法示例
Mar 21 Python
python+splinter实现12306网站刷票并自动购票流程
Sep 25 Python
python requests爬取高德地图数据的实例
Nov 10 Python
python学生管理系统
Jan 30 Python
对Python 简单串口收发GUI界面的实例详解
Jun 12 Python
Django 实现将图片转为Base64,然后使用json传输
Mar 27 Python
Python爬虫爬取糗事百科段子实例分享
Jul 31 Python
Django自带用户认证系统使用方法解析
Nov 12 Python
python实现图像随机裁剪的示例代码
Dec 10 Python
学会Python数据可视化必须尝试这7个库
Jun 16 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
将数组写入txt文件 var_export
2009/04/21 PHP
PHP中基本符号及使用方法
2010/03/23 PHP
Yii中render和renderPartial的区别
2014/09/03 PHP
php正则表达式获取内容所有链接
2015/07/24 PHP
php将文件夹打包成zip文件的简单实现方法
2016/10/04 PHP
在thinkphp5.0路径中实现去除index.php的方式
2019/10/16 PHP
Jquery下判断Id是否存在的代码
2011/01/06 Javascript
学习从实践开始之jQuery插件开发 对话框插件开发
2012/04/26 Javascript
js replace替换所有匹配的字符串
2014/02/13 Javascript
JavaScript加入收藏夹功能(兼容IE、firefox、chrome)
2014/05/05 Javascript
iframe子页面与父页面在同域或不同域下的js通信
2014/05/07 Javascript
js获取网页可见区域、正文以及屏幕分辨率的高度
2014/05/15 Javascript
js仿支付宝填写支付密码效果实现多方框输入密码
2016/03/09 Javascript
js仿支付宝多方框输入支付密码效果
2016/09/27 Javascript
jQuery实现的动态文字变化输出效果示例【附演示与demo源码下载】
2017/03/24 jQuery
详解Angular.js中$http拦截器的介绍及使用
2017/07/04 Javascript
js 事件的传播机制(实例讲解)
2017/07/20 Javascript
js实现网页的两个input标签内的数值加减(示例代码)
2017/08/15 Javascript
AngularJS中下拉框的高级用法示例
2017/10/11 Javascript
实例解析ES6 Proxy使用场景介绍
2018/01/08 Javascript
JavaScript代码实现txt文件的上传预览功能
2018/03/27 Javascript
jQuery easyui datagird编辑行删除行功能的实现代码
2018/09/20 jQuery
ZK中使用JS读取客户端txt文件内容问题
2019/11/07 Javascript
javascript canvas API内容整理
2020/02/16 Javascript
jQuery实现高度灵活的表单验证功能示例【无UI】
2020/04/30 jQuery
vue浏览器返回监听的具体步骤
2021/02/03 Vue.js
vue前端和Django后端如何查询一定时间段内的数据
2021/02/28 Vue.js
Python中处理字符串之endswith()方法的使用简介
2015/05/18 Python
Python动刷新抢12306火车票的代码(附源码)
2018/01/24 Python
python傅里叶变换FFT绘制频谱图
2019/07/19 Python
Python抓包并解析json爬虫的完整实例代码
2020/11/03 Python
可持续未来的时尚基础:Alternative Apparel
2019/05/06 全球购物
swtich是否能作用在byte上,是否能作用在long上,是否能作用在String上
2013/07/06 面试题
质量月活动策划方案
2014/03/10 职场文书
怎么写工作检讨书
2014/11/16 职场文书
小学见习报告
2015/06/23 职场文书