#!/usr/bin/env python import sys, os import json import re with open('wordlist.json', 'r', encoding='utf-8') 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, encoding='utf-8') as f: textfile = f.read() for word in wordlist_dict: word = re.escape(word) textfile = re.sub(r"(?\1", textfile) print(textfile)