import re with open('tmp_home_current2.html', 'r', encoding='utf-8') as f: html = f.read() old_cred = """
Credentials
Confidential. Insightful. Practical.
""" new_cred = """Credentials
Confidential. Insightful. Practical.
""" if old_cred in html: html = html.replace(old_cred, new_cred) else: print("Warning: could not find old_cred without newlines") old_p2 = """$550 / hour
""" new_p2 = """$500 / hour
""" if old_p2 in html: html = html.replace(old_p2, new_p2) else: print("Warning: could not find old_p2 without newlines") with open('tmp_home_current3.html', 'w', encoding='utf-8') as f: f.write(html)