为什么即使我等待网站完成加载也得不到数据?
Why don't I get data even if I wait for the site to finish loading?
我有一个问题涉及我要从中获取数据的网站的功能。
实际上,当我下载网站的 HTML 时,它会下载所有内容,但不会下载我想要的数据,我注意到当你在我想要的数据出现之前打开网站时,会有一个缓冲 gif,所以我添加了一个延迟许多秒(我也尝试了几分钟,但结果没有改变)以允许 htmlUnit 加载站点,但显然,问题不在于此。我整个下午都在寻找答案,但一无所获。
我给你留下网址:https://www.finderbet.it/surebet/
和代码:
import com.gargoylesoftware.htmlunit.*;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import java.io.IOException;
public class Scraper {
private static final String url="https://www.finderbet.it/surebet/";
public static void main(String[] args) {
WebClient client= new WebClient(BrowserVersion.BEST_SUPPORTED);
client.getOptions().setCssEnabled(false);
client.getOptions().setJavaScriptEnabled(false);
try {
HtmlPage page= client.getPage(url);
Thread.sleep(10000);
System.out.println(page.asXml());
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
您看到的那个“缓冲区”是一个 AJAX 调用——如果您直接调用它.. 它会提供您要查找的数据。浏览器
finderbet.it/wp-json/bet/v1/getItems
您可以使用get
参数过滤JSON包括分页IE
https://www.finderbet.it/wp-json/bet/v1/getItems?surebet_do_set_filter=NOPE&action-set-filtri_nonce=d20ddf9c95&bookmakers=&sports=&data_evento_da=&data_evento_a=&profitto_min=&puntate=tutti&orderBy=profitto&order=desc&page=1
分解为:
https://www.finderbet.it/wp-json/bet/v1/getItems
surebet_do_set_filter=NOPE
action-set-filtri_nonce=d20ddf9c95
bookmakers=
sports=
data_evento_da=
data_evento_a=
profitto_min=
puntate=tutti
orderBy=profitto
order=desc
page=1
我有一个问题涉及我要从中获取数据的网站的功能。 实际上,当我下载网站的 HTML 时,它会下载所有内容,但不会下载我想要的数据,我注意到当你在我想要的数据出现之前打开网站时,会有一个缓冲 gif,所以我添加了一个延迟许多秒(我也尝试了几分钟,但结果没有改变)以允许 htmlUnit 加载站点,但显然,问题不在于此。我整个下午都在寻找答案,但一无所获。
我给你留下网址:https://www.finderbet.it/surebet/
和代码:
import com.gargoylesoftware.htmlunit.*;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import java.io.IOException;
public class Scraper {
private static final String url="https://www.finderbet.it/surebet/";
public static void main(String[] args) {
WebClient client= new WebClient(BrowserVersion.BEST_SUPPORTED);
client.getOptions().setCssEnabled(false);
client.getOptions().setJavaScriptEnabled(false);
try {
HtmlPage page= client.getPage(url);
Thread.sleep(10000);
System.out.println(page.asXml());
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
您看到的那个“缓冲区”是一个 AJAX 调用——如果您直接调用它.. 它会提供您要查找的数据。浏览器
finderbet.it/wp-json/bet/v1/getItems
您可以使用get
参数过滤JSON包括分页IE
https://www.finderbet.it/wp-json/bet/v1/getItems?surebet_do_set_filter=NOPE&action-set-filtri_nonce=d20ddf9c95&bookmakers=&sports=&data_evento_da=&data_evento_a=&profitto_min=&puntate=tutti&orderBy=profitto&order=desc&page=1
分解为:
https://www.finderbet.it/wp-json/bet/v1/getItems
surebet_do_set_filter=NOPE
action-set-filtri_nonce=d20ddf9c95
bookmakers=
sports=
data_evento_da=
data_evento_a=
profitto_min=
puntate=tutti
orderBy=profitto
order=desc
page=1