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);