问题描述:
在用jsoup获取网络数据时出现如下错误:
org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml. Mimetype=application/x-javascript, URL
解决方案:
解决方案主要有三个:
1:String script = Jsoup.connect(url).ignoreContentType(true).execute().body(); 忽略它的返回类型。
2:byte[] bytes = Jsoup.connect(url).ignoreContentType(true).execute().bodyAsBytes();
3:URLConnection conn = new URL(url).openConnection();