I have completed my python script which when run in the terminal does what I need it to do. What is the best way to run the script and save its output to a windows folder as a .html file. Also if there's a cleaner way to set this code up I'm open to suggestions?
from bs4 import BeautifulSoup
import re
with open(r'c:/folder/hello.html', 'r') as f:
html_string = f.read()
soup = BeautifulSoup(html_string)
target = soup.find_all(text=re.compile(r'Note Id'))
for v in target:
v.replace_with(v.replace('Note Id','Note Id_Test'))
target1 = soup.find_all(text=re.compile(r'Entity Id'))
for v in target1:
v.replace_with(v.replace('Entity Id','Entity Id_Test'))
target2 = soup.find_all(text=re.compile(r'Entity Name'))
for v in target2:
v.replace_with(v.replace('Entity Name','Entity Name_Test'))
target3 = soup.find_all(text=re.compile(r'Note Detail'))
for v in target3:
v.replace_with(v.replace('Note Detail','Note Detail_Test'))
target4 = soup.find_all(text=re.compile(r'Create Date'))
for v in target4:
v.replace_with(v.replace('Create Date','Create Date_Test'))
Print(soup)