在構建了博客列表之後,要做一些校驗,比如判斷有沒有重的或漏的,就要把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比較差異。