UnsupportedMimeTypeException about Jsoup

来源:互联网 发布:linux有ping命令吗 编辑:程序博客网 时间:2024/05/22 04:25

问题描述:

在用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();   

0 0
原创粉丝点击