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();
======================我抓取得是返回json的页面,用上面的方法解决了

猜你喜欢

转载自blog.csdn.net/qq_29347295/article/details/81453780
今日推荐