import socket
tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcp_socket.connect(("www.lautung.com", 80))
request_line = "GET / HTTP/1.1
"
request_header = "Host:www.lautung.com
"
request_blank = "
"
request_data = request_line + request_header + request_blank
tcp_socket.send(request_data.encode("gbk"))
recv_data = tcp_socket.recv(40960)
recv_text = recv_data.decode()
local_num = recv_text.find("
")
html_text = recv_text[local_num:]
with open("index.html", "w") as f:
f.write(html_text)
tcp_socket.close()