我正在尝试从此网站http://www.mof.gov.cn/获取一些数据,并且我继续获取EOFException:
connect命令非常基本:
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)
知道为什么吗?非常感谢。
答案 0 :(得分:3)
请使用有效的字符集名称尝试此操作:
文档doc = Jsoup.parse(新网址(“http://www.mof.gov.cn/”)。openStream(),“UTF-8”,“http://www.mof.gov.cn/”);