0
我想制作一个程序,可以发送HTTP发布请求并进行响应。用Python发送HTTP帖子
所以,我要发这个帖子:
POST https: //example.com/index.php?s=&&app=box&module=ajax§ion=coreAjax&secure_key=&type=submit&lastid=87311&global=1 HTTP/1.1
Host: example.com
Connection: keep-alive
Content-Length: 10
Accept: text/javascript, text/html, application/xml, text/xml, */*
X-Prototype-Version: 1.7.2
Origin: https://example.com
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36
Content-type: application/x-www-form-urlencoded; charset=UTF-8
Referer: https://x.com/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.8
Cookie: cookieconsent_status=dismiss;
然后输入请求体:
message= # Which I will make: "message= %s" % (messagex))
但我不知道该怎么向他们发送和不容似乎找到任何方式在线,有人可以帮忙吗?
你有看过http://requests.readthedocs.io/en/master/?或者httplib库? – ValLeNain
@ValLeNain是的,但我对Python真的很陌生,并且对如何做到这一点不太了解:/ – Hubgum
阅读段落自定义标题和更复杂的POST请求(http://requests.readthedocs.io/en/master/user/quickstart /#custom-headers)这正是你所需要的,非常简单。请记住,在发布StackOverflow之前,你必须尝试一些东西;) – ValLeNain