gpt4 book ai didi

java - 连接错误 : "org.jsoup.UnsupportedMimeTypeException: Unhandled content type"

转载 作者:IT老高 更新时间:2023-10-28 21:11:28 27 4
gpt4 key购买 nike

当我尝试打开一个链接以使用 jsoup 进行解析时出现错误。

连接命令:

Document doc = Jsoup.connect("http://www.rfi.ro/podcast/emisiune/174/feed.xml")
.timeout(10 * 1000).get();

抛出的错误:

Exception in thread "main" org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml. Mimetype=application/rss+xml; charset=utf-8, URL=http://www.rfi.ro/podcast/emisiune/174/feed.xml
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:453)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:410)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:164)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:153)
at podcast.Pods.main(Pods.java:41)

最佳答案

使用 ignoreContentType() (see doc here):

String myURL = "http://www.rfi.ro/podcast/emisiune/174/feed.xml";
Document pod = Jsoup.connect(myURL).ignoreContentType(true).get();

关于java - 连接错误 : "org.jsoup.UnsupportedMimeTypeException: Unhandled content type",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16327105/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com