import sys with open('tmp_home_current.html', 'r', encoding='utf-8') as f: html = f.read() img_block_str = """
Kevin McKeand
""" if img_block_str in html: html = html.replace(img_block_str + '\n\n', '') html = html.replace(img_block_str + '\n', '') html = html.replace(img_block_str, '') else: print("Error: Could not find exact image block string.") sys.exit(1) new_img_block_str = img_block_str.replace('', '') new_img_block_str = new_img_block_str.replace('
', '
') new_img_block_str = new_img_block_str.replace('max-width:100%', 'width:275px;max-width:100%') # Add the new block at the very top of the html html = new_img_block_str + '\n\n' + html old_saying = """

What they're Saying

""" new_saying = """

What they're Saying

""" if old_saying in html: html = html.replace(old_saying, new_saying) else: print("Error: Could not find exact saying block string.") sys.exit(1) with open('tmp_home_current.html', 'w', encoding='utf-8') as f: f.write(html) print("Success.")