跪求!!!用jsoup提交表单时报错 HTTP error fetching URL,Status=405

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了跪求!!!用jsoup提交表单时报错 HTTP error fetching URL,Status=405相关的知识,希望对你有一定的参考价值。

拜托各位大神了!!这个怎么解决

错误:
exception in thread "main" org.jsoup.HttpStatusException: HTTP error fetching URL. Status=405, URL=http://jwxt.sdu.edu.cn:7777/zhxt_bks/xk_login.html

这个status=405是什么东东啊 ??

代码如下:

//建立链接的代码
Connection conn=Jsoup.connect(url);
conn.header("(Request-Line)", "POST /pls/wwwbks/bks_login2.login?jym2005=10764.49974259798 HTTP/1.1");
conn.header("Accept","text/html, application/xhtml+xml, */*");
conn.header("Accept-Encoding", "gzip, deflate");
conn.header("Accept-Language", "zh-CN");
conn.header("Pragma", "no-cache");
conn.header("Connection", "Keep-Alive");
conn.header("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
conn.header("Host", "jwxt.sdu.edu.cn:7777");
conn.header("Referer", "http://jwxt.sdu.edu.cn:7777/zhxt_bks/xk_login.html");
conn.header("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; MALC)");

//提交表单的代码
Response res =conn.ignoreContentType(true)

.data("stuid","用户名","pwd","密码")
.method(Method.POST)
.execute();

跪谢啊!!!解决了绝对加分重谢!!

参考技术A HTTP请求错误
405 - 用来访问本页面的 HTTP 谓词不被允许(方法不被允许)追问

谢谢您!具体应该怎么解决阿?跪谢!

本回答被提问者采纳
参考技术B 设置userAgent("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"),伪装成浏览器就好了

ubuntu 下载软件时报错问题解决

Err:1 http://101.44.1.126/files/3083000004693134/cdn.packages.deepin.com/deepin xenial/main i386 fonts-dejavu-extra all 2.35-1
Writing more data than expected (1751021 > 1748684)
E: Failed to fetch http://101.44.1.126/files/3083000004693134/cdn.packages.deepin.com/deepin/pool/main/f/fonts-dejavu/fonts-dejavu-extra_2.35-1_all.deb Writing more data than expected (1751021 > 1748684)

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
解决方式:
ubuntn默认下载路径的源是国外的下载很慢换成国内的下载路径会好很多 在ubuntu应用搜索框(左上脚那个)中输入software
1.software&Updates 应用点击software 2.在弹出的界面中的download中选择other 3.在之后弹出的框中选到china 4.在里面选个源 我选的是阿里云的源 5.然后点击Choose server 就可以了 在弹出的框中输入你的root密码点击authenticate 之后点击close 在reload就可以了

 

以上是关于跪求!!!用jsoup提交表单时报错 HTTP error fetching URL,Status=405的主要内容,如果未能解决你的问题,请参考以下文章

用jsoup解析HTML时报错;java.lang.noclassdeffounderror:org/jsoup/Jsoup

Django在以post的方式提交表单时报错CSRF verification failed. Request aborted的解决办法

通过html页面的表单提交中文数据,Java后台出现乱码。跪求大神解答。

JSOUP:设置表单数据

使用maven-shade-plugin打包maven项目,项目使用spring框架,打包成jar时报错,跪求大佬,弄了好久没出?

禁止表单提交