Initial
This commit is contained in:
parent
f9e1fa72c9
commit
6567bdc224
|
@ -0,0 +1,39 @@
|
|||
# JW!! Browser - A simple plain text python web browser
|
||||
# Version 0.1a
|
||||
|
||||
# Import modules
|
||||
import urllib.request
|
||||
import os
|
||||
#import html2text
|
||||
#from bs4 import BeautifulSoup
|
||||
from html.parser import HTMLParser
|
||||
|
||||
# Meta
|
||||
print("JW!! Browser Version 0.1a")
|
||||
print("This program is in in alpha, this program does not have full functionality yet")
|
||||
|
||||
# Asks the user which website they want to view.
|
||||
URL = input("What URL would you like to view? Make sure you add /index.html to the end of the URL: ")
|
||||
|
||||
# Downloads the website to view it
|
||||
urllib.request.urlretrieve(URL, 'page.html')
|
||||
|
||||
# Determine which operating system is being ran
|
||||
OS = os.name
|
||||
|
||||
# Show page as plain text
|
||||
class HTMLFilter(HTMLParser):
|
||||
text = "page.txt"
|
||||
def handle_data(self, data):
|
||||
self.text+= data
|
||||
|
||||
f = HTMLFilter()
|
||||
f.feed("page.html")
|
||||
print(data)
|
||||
|
||||
# Uses the proper command for the operating system
|
||||
#if OS == "nt":
|
||||
# os.system("notepad.exe page.html")
|
||||
#elif OS == "posix":
|
||||
# os.system("cat page.html")
|
||||
|
Loading…
Reference in New Issue