看了leetcode提交代码的接口,想模拟提交过程,但把从浏览器看到的所有头部都发过去了还是返回405.接口是https://leetcode.com/problems/longest-common-prefix/interpret_solution/相关请求header是(去除cookie后)Accept:application/json, text/plain, */*Accept-Encoding:gzip, deflateAccept-Language:zh-CN,zh;q=0.8,en;q=0.6Connection:keep-aliveContent-Length:177Content-Type:application/json;charset=UTF-8Cookie:PHPSESSID=; csrftoken=; _ga=GA1.2.1819762987.1461496079; __atuvc=4%7C18%2C22%7C19%2C12%7C20DNT:1Host:leetcode.comOrigin:https://leetcode.comReferer:https://leetcode.com/problems/longest-common-prefix/User-Agent:Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.76 Mobile Safari/537.36X-CSRFToken:WWVGhawGNjGhzCUlYA3YDzKN0kxfEhoNX-Requested-With:XMLHttpRequest用jsoup和postmen把全部参数都发送了还是不成功, 一直返回405. 请问这是某种反爬虫措施还是我哪里有错?尝试了get和post都不行
2 回答
慕村225694
TA贡献1880条经验 获得超4个赞
问题解决, 但是没有找到解决方法.
确定请求方法是post, 跟换请求库为Okhttp 3.0后请求成功(返回200), 但是数据乱码, 把header里面相关请求类型, 压缩类型(encoding, content-type)等删除后获取成功.
添加回答
举报
0/150
提交
取消