猿问

浏览器抓到是leetcode提交代码是post请求, 但模拟时返回405

看了leetcode提交代码的接口,想模拟提交过程,但把从浏览器看到的所有头部都发过去了还是返回405.接口是
https://leetcode.com/problems/longest-common-prefix/interpret_solution/
相关请求header是(去除cookie后)

Accept:application/json, text/plain, */*

Accept-Encoding:gzip, deflate

Accept-Language:zh-CN,zh;q=0.8,en;q=0.6

Connection:keep-alive

Content-Length:177

Content-Type:application/json;charset=UTF-8

Cookie:PHPSESSID=; csrftoken=; _ga=GA1.2.1819762987.1461496079; __atuvc=4%7C18%2C22%7C19%2C12%7C20

DNT:1

Host:leetcode.com

Origin:https://leetcode.com

Referer: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.36

X-CSRFToken:WWVGhawGNjGhzCUlYA3YDzKN0kxfEhoN

X-Requested-With:XMLHttpRequest

用jsoup和postmen把全部参数都发送了还是不成功, 一直返回405. 请问这是某种反爬虫措施还是我哪里有错?尝试了get和post都不行

桃花长相依
浏览 586回答 2
2回答

慕村225694

问题解决, 但是没有找到解决方法.确定请求方法是post, 跟换请求库为Okhttp 3.0后请求成功(返回200), 但是数据乱码, 把header里面相关请求类型, 压缩类型(encoding, content-type)等删除后获取成功.
随时随地看视频慕课网APP

相关分类

Java
我要回答