#socket library
import socket
Q1:what’s the meaning of these two parameter?(socket.AF_AF_INET, socket.SOCK_STREAM)
mysocket = socket.socket(socket.AF_AF_INET, socket.SOCK_STREAM)
mysocket.connnect((host,port)) #tips: transmit a 2-tuple
Q2: what’s the meaning of HTTP/1.0 \r\n\r\n
cmd = ‘GET balabalalba HTTP/1.0\r\n\r\n’.encode()#encode() transfer string to UNICODE
while True:
data = mysocket.recv(512) #recive 512 bytes of data
if(length(data) < 1):#end
break
print(data.decode())# decode() transfer UNICODE to string
mysocket.close() #close connection
#Hypertext Transfer Protocol(HTTP)
href–links to another documents
#Explore HTTP by developer console
metadata in headers tells the browser how to interpret the body of the response document