import socket
# 发送的http包头
header_send = b'GET /nav/blog HTTP/1.1\r\nHost: %s\r\nConnection: close\r\n\r\n'
# 目的地址
ip_dst = 'www.link-nemo.com'
# 目的端口
port_dst = 80
def connect():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((ip_dst, port_dst))
s.send(header_send % ip_dst.encode())
buffer = []
while True:
# 每次最多接收1k字节:
d = s.recv(1024)
if d:
buffer.append(d)
else:
break
print(buffer)
if __name__ == '__main__':
connect()