use HttpConnection.Response's method contentType to get content type and decide accordingly
Connection.Response res = Jsoup.connect("http://www.google.com/").timeout(10*1000).execute();
String contentType=res.contentType();
문제
I am parsing web pages in auto mode with JSOUP and get such error:
org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml. Mimetype=image/jpeg,
As solution, it is offered here to use ignoreContentType() function that will 'force jsoup to ignore the content-type and parse the response as HTML'. I do not want to parse picture as HTML, so is there any way to handle such exceptions or get content type like:
if (Contenttype == 'text' or Contenttype == 'xml' or ...what_ever_other_text_format)
parse
else
do_nothing.
해결책
use HttpConnection.Response's method contentType to get content type and decide accordingly
Connection.Response res = Jsoup.connect("http://www.google.com/").timeout(10*1000).execute();
String contentType=res.contentType();