python爬虫基础教程115_Python解析网页源代码中的115网盘链接实例

本文通过Python代码示例,讲解如何解析网页源代码以提取115网盘的链接。利用正则表达式匹配URL,最终成功获取一系列115网盘的下载链接。
摘要由CSDN通过智能技术生成

本文实例讲述了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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值