2

我正在尝试从该网站http://www.mof.gov.cn/获取一些数据,并且我不断收到 EOFException:

连接命令非常基本: Jsoup.connect("http://www.mof.gov.cn/").ignoreContentType(true).userAgent("Mozilla/5.0(Windows NT 6.1; rv:23.0) Gecko/20100101 Firefox/23.0").timeout(30000).get();

EOFException 是:

java.io.EOFException
at java.util.zip.GZIPInputStream.readUByte(GZIPInputStream.java:207)
at java.util.zip.GZIPInputStream.readUShort(GZIPInputStream.java:197)
at java.util.zip.GZIPInputStream.readUInt(GZIPInputStream.java:189)
at java.util.zip.GZIPInputStream.readTrailer(GZIPInputStream.java:179)
at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:94)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:256)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
at java.io.FilterInputStream.read(FilterInputStream.java:90)
at org.jsoup.helper.DataUtil.readToByteBuffer(DataUtil.java:124)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:464)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:410)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:164)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:153)
at com.staging.Crawfinance.main(Crawfinance.java:30)

知道为什么吗?非常感谢。

4

1 回答 1

3

请使用有效的字符集名称尝试此操作:

文档 doc = Jsoup.parse(new URL(" http://www.mof.gov.cn/ ").openStream(), "UTF-8", " http://www.mof.gov.cn/ " );

于 2013-09-18T14:29:04.843 回答