我在阅读关于部分GET请求的内容,这会使服务器在一段时间后超时连接。如何发送部分GET请求?
import socket, sys
host = sys.argv[1]
request = "GET / HTTP/1.1\nHost: "+host+"\n\nUser-Agent:Mozilla 5.0\n" #How could I make this into a partial request?
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, 80))
s.sendto(request, (host, 80))
response = s.recv(1024)
我该怎么做呢?
urllib
、requests
这样的模块呢? - falsetru