は
DATA = ("POST /example/email.php HTTP/1.1\r\n" # send headers
"HOST: example.com\r\n"
"Accept: *\r\n"
"Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n"
"Referer: http://example.com/example/\r\n"
"\r\n" # blank line seperating headers from body
"action=subscribeme&[email protected]\r\n") #actual post payload data
でそれを試してみて、あなたは答えを得る必要があります。
import socket
HOST = 'www.example.com'
PORT = 80
DATA = ("POST /example/email.php HTTP/1.1\r\n" # send headers
"HOST: example.com\r\n"
"Accept: *\r\n"
"Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n"
"Referer: http://example.com/example/\r\n"
"\r\n" # blank line seperating headers from body
"action=subscribeme&[email protected]\r\n") #actual post payload data
def tcp_client():
client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect((HOST, PORT))
client.send(DATA)
response = client.recv(4096)
print response
if __name__ == '__main__':
tcp_client()
を使用して
私は明らかに誤りはなく、完全に対応している
HTTP/1.1 411 Length Required
Content-Type: text/html
Content-Length: 357
Connection: close
Date: Mon, 08 Aug 2016 11:23:16 GMT
Server: ECSF (ewr/1443)
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>411 - Length Required</title>
</head>
<body>
<h1>411 - Length Required</h1>
</body>
</html>
を取得します。
DATA = ("POST /example/email.php HTTP/1.1\r\n" # send headers
"HOST: example.com\r\n"
"Accept: *\r\n"
"Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n"
"Content-Length: 41\r\n" #fixes error 411
"Referer: http://example.com/example/\r\n"
"\r\n" # blank line seperating headers from body
"action=subscribeme&[email protected]") #actual post payload data
で
は、私は通常の404 Not Found
を取得します。
何らかの応答があるはずです。 200/404/500またはタイムアウト。 – DeepSpace
あなたのデータを印刷して何が得られるかを確認 –
@DeepSpaceエラーはありません。ソケットタイムアウトを5秒に設定しました。さらに、同じhttpパケットがカールと郵便配達員でうまく動作しています –