Jsoup打开链接报错:org.jsoup.UnsupportedMimeTypeException: Unhandled content type Must be text/*

导读:本篇文章讲解 Jsoup打开链接报错:org.jsoup.UnsupportedMimeTypeException: Unhandled content type Must be text/*,希望对大家有帮助,欢迎收藏,转发!站点地址:www.bmabk.com

Jsoup打开链接报错:org.jsoup.UnsupportedMimeTypeException: Unhandled content type Must be text/*

样例代码

 String yourUrl = "www.123.com";
 Connection connect = Jsoup.connect(yourUrl);

报错详情

org.jsoup.UnsupportedMimeTypeException: Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml. Mimetype=application/json, URL=https://www.123.com
at org.jsoup.helper.HttpConnection

R

e

s

p

o

n

s

e

.

e

x

e

c

u

t

e

(

H

t

t

p

C

o

n

n

e

c

t

i

o

n

.

j

a

v

a

:

770

)

a

t

o

r

g

.

j

s

o

u

p

.

h

e

l

p

e

r

.

H

t

t

p

C

o

n

n

e

c

t

i

o

n

Response.execute(HttpConnection.java:770) at org.jsoup.helper.HttpConnection

Response.execute(HttpConnection.java:770)atorg.jsoup.helper.HttpConnectionResponse.execute(HttpConnection.java:706)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:299)

解决办法

在connect后加入如下代码 .ignoreContentType(true).

String yourUrl = "www.123.com";
Connection connect = Jsoup.connect(yourUrl)
                .ignoreContentType(true);

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/94927.html

(0)
小半的头像小半

相关推荐

极客之音——专业性很强的中文编程技术网站,欢迎收藏到浏览器,订阅我们!