JSoup请求的URL更改

问题描述:

我试图使用JSoup访问java在线api。 通过我的浏览器,我可以导航到网址,并得到json数据。但是,如果我使用Jsoup,那么URL会被更改,'/ api'会从中删除。 例如:https://www.onehash.com/api/archived_contest/122/ 我可以通过浏览器打开它,但如果我使用jsoup连接到它,则url变为 https:/ /www.onehash.com/archived_contest/122/并返回404错误。 (插入的空间,因为不能超过2个链接) 概述网址:https://www.onehash.com/api/disciplines_json/我可以连接到Jsoup只是罚款,虽然...JSoup请求的URL更改

有没有人有这样的想法?我曾尝试在头上发送一个useragent,但无济于事。

我用于连接的代码是:

Jsoup.connect("https://www.onehash.com/api/archived_contest/122") 
    .userAgent("Mozilla") 
    .ignoreContentType(true) 
    .get(); 

其抛出HttpStatusException

+0

我编辑了一些代码的帖子 –

随着它工作结束斜线:

//                v--- Slash here 
Jsoup.connect("https://www.onehash.com/api/archived_contest/122/") 
    .userAgent("Mozilla") 
    .ignoreContentType(true) 
    .get(); 

它还返回浏览器404没有结尾的斜线。

+0

非常感谢!我怎么没有注意到这T.T –