Не удается получить HTML-документ из соединения Jsoup для определенного веб-сайта - PullRequest
0 голосов
/ 10 ноября 2018

Когда я пытаюсь запросить HTML-документ после подключения к этому конкретному веб-сайту (эта ошибка не возникала, когда я использовал Jsoup для другого веб-сайта), я получаю следующую ошибку.

Код:

LocalDateTime date = LocalDateTime.now();
Document doc = Jsoup.connect("https://www.twicenest.com/index.php?mid=schedule&pGanjioption=1&pYear=" + date.getYear() + "&pMonth=" + date.getMonthValue()).userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36").get();

// do something with doc

Ошибка:

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$154(LauncherImpl.java:182)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.EOFException: Unexpected end of ZLIB input stream
    at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:240)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
    at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:117)
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
    at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
    at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
    at org.jsoup.internal.ConstrainableInputStream.read(ConstrainableInputStream.java:64)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
    at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
    at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
    at java.io.InputStreamReader.read(InputStreamReader.java:184)
    at java.io.BufferedReader.fill(BufferedReader.java:161)
    at java.io.BufferedReader.read1(BufferedReader.java:212)
    at java.io.BufferedReader.read(BufferedReader.java:289)
    at java.io.Reader.read(Reader.java:140)
    at org.jsoup.parser.CharacterReader.bufferUp(CharacterReader.java:53)
    at org.jsoup.parser.CharacterReader.consume(CharacterReader.java:98)
    at org.jsoup.parser.TokeniserState$40.read(TokeniserState.java:803)
    at org.jsoup.parser.Tokeniser.read(Tokeniser.java:57)
    at org.jsoup.parser.TreeBuilder.runParser(TreeBuilder.java:51)
    at org.jsoup.parser.TreeBuilder.parse(TreeBuilder.java:45)
    at org.jsoup.parser.Parser.parseInput(Parser.java:39)
    at org.jsoup.helper.DataUtil.parseInputStream(DataUtil.java:153)
    at org.jsoup.helper.HttpConnection$Response.parse(HttpConnection.java:851)
    at org.jsoup.helper.HttpConnection.get(HttpConnection.java:296)
    at view.ONCEApp.start(ONCEApp.java:51)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$161(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$174(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
    ... 1 more

Я пытался читать с этого сайта, используя встроенные средства Java (URL, URLConnection), и преуспел в этом, используя их. Но они не предоставляют те же методы фильтрации, что и Jsoup.

...