LoginSignup
1
0

More than 5 years have passed since last update.

[jsoup]ドキュメントの全量を取得する方法

Posted at

全量取得できていない!?

とあるページをjsoupにて取得しselectorで要素を取得した際、本来ある数より少ない結果となりました。
ドキュメントのtext()を見ても取得要素が足りていない・・・(困)

maxBodySize(0)の利用

これだけでした。

Document doc = Jsoup
          .connect("https://xxx.xxx.xxx/")
          .userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36")
          .timeout(1000 * 60)
          .maxBodySize(0)
          .get();

参考

・リファレンス
  https://jsoup.org/apidocs/org/jsoup/Connection.html#maxBodySize-int-
  「The default maximum is 1MB」とありました。意外と小さい?ですね。

・参考にさせて頂きましたサイト様
  https://jmchung.github.io/blog/2013/10/25/how-to-solve-jsoup-does-not-get-complete-html-document/

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0