You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

22 lines
682 B

import sys, os
import json
import re
with open('wordlist.json', 'r') as f:
wordlist_dict = json.load(f)
path = "static/files/"
for path, subdirs, files in os.walk(path):
for name in files:
if name.endswith('html'):
file = os.path.join(path, name)
with open(file, 'r+') as f:
textfile = f.read()
for word in wordlist_dict:
# word = re.escape(word)
textfile = re.sub(r"(?<!<)(?<!</)(?<!ge\?)\b(%s)\b" %word, r"<a href='/diverge?search=\1'>\1</a>", textfile)
f.truncate(0)
f.write(textfile)
f.truncate()
# print(textfile)