Python解析网页源代码中的115网盘链接实例

 更新时间:2014年09月30日 14:24:43   投稿:shichen2014  
这篇文章主要介绍了Python解析网页源代码中的115网盘链接实例,主要采用了正则表达式re模块来实现该功能,需要的朋友可以参考下

本文实例讲述了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二维键值数组生成转json的例子

    python二维键值数组生成转json的例子

    今天小编就为大家分享一篇python二维键值数组生成转json的例子,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2019-12-12
  • Python采集股票数据并制作可视化柱状图

    Python采集股票数据并制作可视化柱状图

    这篇文章主要介绍了如何利用Python采集股票数据并制作可视化柱状图,文中的示例代码讲解详细,快来跟上小编一起动手尝试一下吧
    2022-04-04
  • Django项目配置连接多个数据库的方法记录

    Django项目配置连接多个数据库的方法记录

    最近在进行django项目开发的时候,遇到了需要连接两个MySQL数据库的问题,下面这篇文章主要给大家介绍了关于Django项目配置连接多个数据库的相关资料,需要的朋友可以参考下
    2022-05-05
  • Python实现创建模块的方法详解

    Python实现创建模块的方法详解

    导入一个模块,我们一般都会使用 import 关键字,但有些场景下 import 难以满足我们的需要。所以除了 import 之外还有很多其它导入模块的方式,下面就来介绍一下
    2022-07-07
  • M1芯片Mac上Anaconda的暂时替代(miniforge)

    M1芯片Mac上Anaconda的暂时替代(miniforge)

    这篇文章主要介绍了M1芯片Mac上Anaconda的暂时替代(miniforge),文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2021-03-03
  • python 中文字符串的处理实现代码

    python 中文字符串的处理实现代码

    python中直接将一个中文字符串赋值给一个变量使用的是utf-8格式的编码,以下为证.
    2009-10-10
  • Python实现微信中找回好友、群聊用户撤回的消息功能示例

    Python实现微信中找回好友、群聊用户撤回的消息功能示例

    这篇文章主要介绍了Python实现微信中找回好友、群聊用户撤回的消息功能,结合实例形式分析了Python基于微信itchat模块实现针对撤回消息的查看功能相关操作技巧,需要的朋友可以参考下
    2019-08-08
  • 详解Flask前后端分离项目案例

    详解Flask前后端分离项目案例

    这篇文章主要介绍了Flask前后端分离项目案例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2020-07-07
  • 解决uWSGI的编码问题详解

    解决uWSGI的编码问题详解

    最近在用Flask 写的应用通过 Supervisor+uWSGI 部署到正式服务器上时出现了错误,通过查找相关的资料终于解决了,所以想着分享出来给大家,下面这篇文章主要介绍了解决uWSGI的编码问题的相关资料,需要的朋友可以参考下。
    2017-03-03
  • 在Python中定义函数并调用的操作步骤

    在Python中定义函数并调用的操作步骤

    这篇文章主要介绍了在Python中如何定义函数并调用它,函数的定义和调用是Python编程中最基本也是最重要的概念之一,掌握它们对于进行有效的Python编程至关重要,需要的朋友可以参考下
    2024-01-01

最新评论