我们发现,阅读量的位置都有一颗小眼睛,对应的是readCountWhite.png,这个要注意到。
按ctrl+F搜索关键字readCountWhite.png,会发现凡是这样的字段的下面一行都会有阅读量的数字:
readCount.py
txt = open("C:/Users/13529/Desktop/1.txt", "r", encoding='utf-8').read() # 上一步中的1.txt文件
# print(len(txt.split("n"))) 输出总行数
n=len(txt.split("n")) # n作为文件的总行数
txt=txt.split("n") # 将一连串的文本分行
readtot=0 # 总阅读量
for i in range(0,n): # 遍历每一行
# 如果找到之前的字符串,那么就将其下一行的字符串转化为数字与总阅读量相加
if txt[i].find('')!=-1:
if(txt[i+1].find('class')==-1):
print(txt[i+1].lstrip())
# 去掉数字的左边空格,然后转化为int相加
readtot+=(int)(txt[i+1].lstrip())
print("总访问量:",readtot)
6.运行文件
我们就统计出了最终的访问量!


