Установил openserver и пробую получить исходники главной страницы.
import socket HOST = '127.0.0.1' PORT = 80 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) s.send(b"Hello! \n") # без него соединение просто закрывается data = s.recv(1024) print(data.decode("utf-8")) s.close()
В итоге получаю
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Cannot process request!</title> <link rev="made" href="mailto:%5bno%20address%20given%5d" /> <style type="text/css"><!--/*--><![CDATA[/*><!--*/ body { color: #000000; background-color: #FFFFFF; } a:link { color: #0000CC; } p, address {margin-left: 3em;} span {font-size: smaller;} /*]]>*/--></style> </head> <body> <h1>Cannot process request!</h1> <p> The server does not support the action requested by the browser. </p> <p> If you think this is a server error, please contact the <a href="mailto:%5bno%20address%20given%5d">webmaster</a>.
Помогите, пожалуйста, отправить корректный запрос
