I am wondering if there is a way to save the html in my file with a specific structured format. Right now the output of this script is just bunched up letters and numbers. Is there a way it could be structured ? for example: 111.111.111.11:111 222.222.222.22:22 (IP Format)
Any help is appreciated!
import urllib.request
import re
ans = True
while ans:
print("""
- Menu Selection -
1. Automatic
2. Automatic w/Checker
3. Manual
4. Add to list
5. Exit
""")
ans = input('Select Option : ')
if ans =="1":
try :
with urllib.request.urlopen('http://www.mywebsite.net') as response:
html = response.read()
html = str(html)
html = re.sub(r'([a-z][A-Z])', '', html)
f = open('text.txt','a')
f.write(html)
f.close()
print('Data(1) saved.')
ans = True
except :
print('Error on first fetch.')