I am attempting to create a simple web browser in Python. I know it is difficult, I know that it is impractical, but I wish to do so for the sake of learning. I have an intermediate knowledge of Python and a basic knowledge of Socket Python. I have created a script following a socket python video that downloads the HTML files from a webpage and prints the HTML code. Below is that script.
import socket
brsr = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
brsr.connect(("data.pr4e.org",80))
cmd = 'GET http://data.pr4e.org/page1.htm HTTP/1.0
'.encode()
brsr.send(cmd)
while True:
data = brsr.recv(512)
if len(data) < 1:
break
print(data.decode(),end='')
brsr.close()
Now, I wish to take this basic script and add two main modifications to it. First of all, I wish to accept user input to allow the client to type the URL in the console and then display the HTML code of the website they requested. Secondly, I would like to know if there is a way to render the HTML code as a webpage instead of an image/pdf. This way the user can interact with the webpage. I have tried using PyQt but it seems outdated and I've had difficulties updating it to be current. If anyone knows how to use PyQt today in a way that works please let me know.
question from:
https://stackoverflow.com/questions/65903543/render-webpage-in-python-from-html-script 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…