This code works. It is designed to retrieve website data directly, parse it, and open it as normal. I will develop it further later. Right now I want to know if there is any way to improve efficiency, such as not using a file etc. I would also like to know if my code could be made more pythonic (this would include PEP standards), or incidences where concatenation would be acceptable to readability. Here is the code:
import urllib.request
from tkinter import *
import webbrowser
import os
proxy_handler = urllib.request.ProxyHandler(proxies=None)
opener = urllib.request.build_opener(proxy_handler)
def navigate(query):
response = opener.open(query)
html = response.read()
return html
def parse(junk):
ugly = str(junk)[2:-1]
lines = ugly.split('\\n')
return lines
while True:
url = input("Path: ")
dump = navigate(url)
content = parse(dump)
with open('cache.html', 'w') as f:
for line in content:
f.write(line)
webbrowser.open_new_tab(os.path.dirname(os.path.abspath(__file__))+'/cache.html')