![](/img/trans.png)
[英]Giving an url, that redirected is a url with spaces, to Jsoup leads to an error. How resolve this?
[英]JSOUP URL with spaces - %20 is taken away
我想阅读以下网址:
https://www.fangraphs.com/liveboxscore.aspx?date=2018-03-29&team=Blue Jays&dh = 0&season = 2018
问题:Blue和Jays之间有空间
通过JSOUP(jsoup.connect(url).get())连接和检索数据时,出现以下错误:
HTTP错误提取URL。 状态= 400,URL = https://www.fangraphs.com/boxscore.aspx?date=2018-03-29&team=Blue Jays&dh = 0&season = 2018
即使用%20替换空格或使用编码,问题仍然存在。
有什么线索我需要做什么?
谢谢
在JSOUP.connect(URL)之前删除URL空间
try {
url = java.net.URLDecoder.decode(url, "UTF-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.