python套接字发送返回404

时间:2019-03-10 10:08:47

标签: python python-sockets

import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('www.py4inf.com', 80))

#mysock.send('GET http://www.py4inf.com/code/romeo.txt HTTP/1.0\n\n')
mysock.send('GET http://www.py4inf.com/code/intro-short.txt HTTP/1.0\n\n')

while True:
    data = mysock.recv(512)
    if ( len(data) < 1 ) :
        break
    print data
mysock.close()

我得到404。我尝试在GET命令中将\n\n替换为\r\n,但一无所获。

  

HTTP / 1.1 404找不到   服务器:nginix

0 个答案:

没有答案