python socket get http
需要注意http1.1和http1.0的區別http1.1要加上Host才可以, http1.0則不用#!/usr/bin/env pythonimport socketsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)sock.connect(('172.17.9.9', 80))#sock.send('GET /
·
需要注意http1.1和http1.0的區別
http1.1要加上Host才可以, http1.0則不用
#!/usr/bin/env python
import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(('172.17.9.9', 80))
#sock.send('GET / HTTP/1.0\r\n\r\n')
sock.send("GET %s HTTP/1.1\r\nHost: %s\r\n\r\n" % ('/', '172.17.8.191'))
data = sock.recv(80960)
print len(data)
更多推荐
已为社区贡献6条内容
所有评论(0)