jsoup抓取网页报错UnsupportedMimeTypeException

在抓腾讯新闻评论时出现如下异常
org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml. 
Mimetype=application/javascript; charset=utf-8, url=http://....

解决办法:将Document commentDoc =  Jsoup.connect(commentUrl).get();改成Document commentDoc =  Jsoup.connect(commentUrl).ignoreContentType(true).get();


 

你可能感兴趣的:(jsoup抓取网页报错UnsupportedMimeTypeException)