# coding: utf-8
import os
import re
path = "./"
# 路径列表
file_list = []
# URL列表
url_list = []
# 打开路径
files = os.listdir(path)
# 找全部文件的路径
for root, dirs, names in os.walk(pash):
for filename in names:
# 只需要.js结尾的文件
if filename[-2:] == "js":
file = str(os.path.join(root, filename))
file_list.append(file)
# 遍历路径获取文件里的URL
for file in file_list:
with open(file, 'rb') as f:
text = f.read()
# re 匹配URL
url_list = url_list + re.findall(r'bankend.endCustService \+ .*?,', text)
# 去重
url_list = list(set(url_list))
# 排序
url_list.sort()
# 写入txt
with open('./Url.txt', 'w') as f:
for i in url_list:
f.write(i + '\n')
网友评论