连接错误:“org.jsoup.UnsupportedMimeTypeException:未处理的内容类型” [英] Connection error: "org.jsoup.UnsupportedMimeTypeException: Unhandled content type"
本文介绍了连接错误:“org.jsoup.UnsupportedMimeTypeException:未处理的内容类型”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我尝试使用 jsoup 打开要解析的链接时,我收到错误。
When I try to open a link to parse with jsoup I get an error.
连接命令:
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()
(请参阅此处的文档):
String myURL = "http://www.rfi.ro/podcast/emisiune/174/feed.xml";
Document pod = Jsoup.connect(myURL).ignoreContentType(true).get();
这篇关于连接错误:“org.jsoup.UnsupportedMimeTypeException:未处理的内容类型”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文