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