python 博客URL列表校驗

在構建了博客列表之後,要做一些校驗,比如判斷有沒有重的或漏的,就要把URL全部提取出來。

代碼:

import re

fp = open('D:\\in.txt', 'r',encoding="utf-8")
html = fp.read()
all_url = re.findall('https://blog.csdn.net/nameofcsdn/article/details/[0-9]+',str(html),re.IGNORECASE)
all_url = list(set(all_url))
fp = open('D:\\csdn.txt', 'w')
s=0
for each in all_url:
    fp.write(each+'\n')
    s=s+1
print(s)

只要把含所有博客URL的正文內容複製粘貼到in.txt中,運行程序即可。

得到所有URL之後還可以用excel排序,用beyond compare比較差異。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章