#!/usr/bin/env python3 import os import fileinput import re import sys file_path_html = 'glife.html' file_path_out = 'mods/modable_glife.html' data = '' with open(file_path_html, 'r') as file: data = file.read() data = re.sub(r"""()""",r"""\1$.ajax({ url: "mod.html", cache: false}) .done(function( html ) { $( "tw-storydata" ).append( html );\2});\3""",data,1, re.S) with open(file_path_out, 'w') as file: file.write(data) print('Done')