该程序去除了whatweb输出的一些乱码
import sys
import os
from pathlib import Path
if __name__ == "__main__":
type = sys.stdout.encoding
file1=Path("out.txt")
if file1.is_file():
os.remove("out.txt")
os.system("whatweb -i url.txt --log-brief=out.txt --no-errors --plugins=my-plugins\plugins-cms") #读取文件名
file_name = "out.txt"
fp1 = open(file_name, "r")
file=Path("result.txt")
if file.is_file():
os.remove("result.txt")
file = open("result.txt",mode="w")
for line in fp1.readlines():
str = line.replace("[1m[34m", "")
str = str.replace("[0m", "")
str = str.replace("[1m", "")
str = str.replace("[32m", "")
str = str.replace("[31m", "")
str = str.replace("[22m", "")
file.write(str.encode('gbk').decode(type))
file.close()
fp1.close()
把程序放在whatweb目录下执行
输入是url.txt,一行一个,输出是result.txt
执行后记得不要关闭,需等执行完毕才能生成result.txt