jsoup没有获得完整的数据 [英] jsoup don't get full data

查看:418
本文介绍了jsoup没有获得完整的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个学校的项目来解析网络代码并像数据库一样使用它。当我尝试关闭数据时( https://www.marathonbet.com/en/betting/足球/ ),我没有得到这一切?

I have a project for school to parse web code and use it like a data base. When I tried to down data from (https://www.marathonbet.com/en/betting/Football/), I didn't get it all?

这是我的代码:

Document doc = Jsoup.connect("https://www.marathonbet.com/en/betting/Football/").get();
Elements newsHeadlines = doc.select("div#container_EVENTS");

for (Element e: newsHeadlines.select("[id^=container_]")) {
    System.out.println(e.select("[class^=block-events-head]").first().text());
    System.out.println(e.select("[class^=foot-market]").select("[class^=event]").text());
} 

获得的结果(这是显示的联赛的最后一个):

for result you get (this is last of displayed leagues):

Football. Friendlies. Internationals All bets Main bets
1. USA 2. Mexico 16 Apr 01:30 +124 7/5 23/10 111/50 +124

在她之上显示所有联赛。

on top of her are all leagues displayed.

为什么我没有获得完整数据?谢谢您的时间!

Why don't I get full data? Thank you for your time!

推荐答案

Jsoup的默认身体响应限制为1MB。您可以使用 maxBodySize (int)

Jsoup has a default body response limit of 1MB. You can change it to whatever you need with maxBodySize(int)


将从(未压缩)连接读取的最大字节数设置为
正文,在连接关闭之前,输入被截断。
默认最大值为1MB。最大尺寸为零被视为
无限金额(仅限于您的耐心和机器上可用的内存
)。

Set the maximum bytes to read from the (uncompressed) connection into the body, before the connection is closed, and the input truncated. The default maximum is 1MB. A max size of zero is treated as an infinite amount (bounded only by your patience and the memory available on your machine).

例如:

Document doc = Jsoup.get(url).userAgent(ua).maxBodySize(0).get();

您可能希望查看连接,关于如何设置请求超时,用户代理等。

You might like to look at the other options in Connection, on how to set request timeouts, the user-agent, etc.

这篇关于jsoup没有获得完整的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆