Python的POST失败。那个参数我没有用到吗?
练习POST,这是POST截取的请求的数据,但是在Python里面没有返回数据。摘要
URL: http://www.enweike.com/index/topic/get_material.html
状态: 200 OK
来源: 网络
地址: 47.115.156.123:80
初始化程序:
jquery-1.10.1.min.js:6:18222
请求
POST /index/topic/get_material.html HTTP/1.1
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: zh-CN,zh-Hans;q=0.9
Accept-Encoding: gzip, deflate
Host: www.enweike.com
Origin: http://www.enweike.com
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15
Connection: keep-alive
Referer: http://www.enweike.com/index/topic/index.html
Content-Length: 21
Cookie: Hm_lpvt_f1164bd0e522184cc4729d5f31a32e2f=1649678552; Hm_lvt_f1164bd0e522184cc4729d5f31a32e2f=1649678481; PHPSESSID=nq55uikmdvcf6j1apjc4tp352k
X-Requested-With: XMLHttpRequest
响应
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Pragma: no-cache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Transfer-Encoding: Identity
Date: Mon, 11 Apr 2022 12:04:14 GMT
Cache-Control: no-store, no-cache, must-revalidate
Connection: keep-alive
Server: nginx
请求数据
MIME类型: application/x-www-form-urlencoded; charset=UTF-8
telephone: 13787967453 如下图,这个手机号应该是已经添加了 老哥ck和电话打下码吧,你这哈哈 忆白学渣 发表于 2022-4-11 20:41
老哥ck和电话打下码吧,你这哈哈
走走走半夜给它打电话聊代码 你py代码咋写的,贴上来啊 随便写都可以啊
import requests
url = 'http://www.enweike.com/index/topic/get_material.html'
data = {'telephone': '13787967453'}
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15'
}
resp = requests.post(url, data=data, headers=headers)
print(resp.text)
你是不是没在headers里加防盗链,网站可能有反爬,在请求头里加上refer和浏览器标识 你用postman等接口调试工具试试 py我只懂一点点,java还可以 from urllib import parse
data = {'telephone': '13787967453'}
data=parse.urlencode(data)
原因:application/x-www-form-urlencoded说明表单数据要进行url编码
页:
[1]
2