【发布时间】:2014-05-12 00:29:06
【问题描述】:
我正在使用 JSOUP 在自动模式下解析网页并得到这样的错误:
org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml. Mimetype=image/jpeg,
作为解决方案,here 提供了使用 ignoreContentType() 函数,该函数将“强制 jsoup 忽略内容类型并将响应解析为 HTML”。我不想将图片解析为 HTML,所以有什么方法可以处理此类异常或获取内容类型,例如:
if (Contenttype == 'text' or Contenttype == 'xml' or ...what_ever_other_text_format)
parse
else
do_nothing.
【问题讨论】: