如何解决Jsoup Java中的HTML错误500
我有两个部件运转良好。 首先,我连接到网站,并将我的登录名和密码输入表单。 我拿到饼干并储存起来
Connection.Response login = Jsoup.connect("website")
.data("name", "name")
.data("password", "password")
.method(Connection.Method.POST)
.execute();
Map<String, String> cookies = login.cookies();
这很好,即使是下一次连接
Document doc1 = Jsoup.connect("website/subpages")
.cookies(cookies)
.get();
doc1运行完美,我可以通过以下方式获取文本:
String pages1 = doc.toString();
但在我的最后一个请求中,我得到了服务器错误500
Document pages2 = Jsoup.connect(website/anothersubpage)
.cookies(cookies)
.get();
我猜问题是最后一个url“网站/另一个子页面”没有设置url。 每次我登录并获得一个新的会话密钥(即我存储在Cookie中的Cookie)时,子页面的URL都会发生变化
在我考虑之后,我将洞页面解析为一个字符串,并使用子字符串来获取新的变量URL
String newLink = text.substring(text.indexOf("Start href"),text.indexOf("End href"));
它成功了,所以我将其存储到了字符串newLink中,即网站上的链接(href“”)。 但现在如果我使用与之前相同的代码:
Document pages2 = Jsoup.connect(my parsed href"..." link)
.cookies(cookies)
.get();
我得到了错误500,我尝试了很多东西,但我无法让它工作了三天
我真的很感激每一个建议或提示
共 (0) 个答案