Python解析網(wǎng)頁源代碼中的115網(wǎng)盤鏈接實例
本文實例講述了python解析網(wǎng)頁源代碼中的115網(wǎng)盤鏈接的方法。分享給大家供大家參考。具體方法分析如下:
其中的1.txt,是網(wǎng)頁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
輸出結(jié)果:
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程序設(shè)計有所幫助
相關(guān)文章
詳解Python安裝tesserocr遇到的各種問題及解決辦法
這篇文章主要介紹了詳解Python安裝tesserocr遇到的各種問題及解決辦法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-03-03matplotlib實現(xiàn)數(shù)據(jù)實時刷新的示例代碼
這篇文章主要介紹了matplotlib實現(xiàn)數(shù)據(jù)實時刷新的示例代碼,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2021-01-01Python基礎(chǔ)教程之增加和去除數(shù)字的千位分隔符
千位分隔符其實就是數(shù)字中的逗號,下面這篇文章主要給大家介紹了關(guān)于Python基礎(chǔ)教程之增加和去除數(shù)字的千位分隔符,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下2023-01-01Python+Selenium+Pytesseract實現(xiàn)圖片驗證碼識別
這篇文章主要介紹了利用Python+Selenium+Pytesseract實現(xiàn)圖片驗證碼識別,文中的示例代碼講解詳細,感興趣的小伙伴可以跟隨小編一起學習一下2022-01-01Python按要求從多個txt文本中提取指定數(shù)據(jù)的代碼示例
本文給大家介紹了Python如何按要求從多個txt文本中提取指定數(shù)據(jù),遍歷文件夾并從中找到文件名稱符合我們需求的多個.txt格式文本文件,文中有相關(guān)的代碼示例供大家參考,具有一定的參考價值,需要的朋友可以參考下2023-12-12python 生成正態(tài)分布數(shù)據(jù),并繪圖和解析
這篇文章主要介紹了python 生成正態(tài)分布數(shù)據(jù),并繪圖和解析,幫助大家更好的利用python進行數(shù)據(jù)分析,感興趣的朋友可以了解下2020-12-12Python?OpenCV中的drawMatches()關(guān)鍵匹配繪制方法
這篇文章主要介紹了Python?OpenCV中的drawMatches()關(guān)鍵匹配繪制方法,文章圍繞主題展開詳細的內(nèi)容介紹,具有一定的參考價值,需要的朋友可以參考一下2022-07-07