gpt4 book ai didi

java - Jsoup链接提取

转载 作者:行者123 更新时间:2023-12-01 15:28:57 24 4
gpt4 key购买 nike

大家好,我正在尝试从 aol 中提取所有 anchor 链接,但它不起作用。相同的代码适用于 yahoo bing。问题是会出现什么问题

Document document5 = Jsoup.connect("www.aol.com").get();
Elements links5 = document5.select("a");

for (Element link5 : links5) {
out.println(link5.attr("href"));
}

最佳答案

根据 the comments on your previous question :

even after im specifying the protocol...only google and aol are not working, same is working with yahoo, bing and ask.... my project is to implement a metasearch engine....i am able to extract links from yahoo, bing and ask...but same does not work with google and aol...what may be the reason..??

他们已阻止您的请求,因为您充当机器人/水蛭,这可能违反他们的服务条款。他们的网站被频繁请求,他们不想不必要地将带宽浪费给机器人/水蛭,而实际上只需要一小部分响应。

使用他们的公共(public)网络服务 API,而不是解析整个网站的 HTML。对于 Google,例如“Google Custom Search API”。其他搜索引擎提供商也提供类似的网络服务。请注意,这些 Web 服务不会返回臃肿的 HTML,而是返回紧凑的 JSON 或 XML 数据,使用 JSON/XML 解析器更容易解析/提取这些数据。

关于java - Jsoup链接提取,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9807186/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com