Java 抓取搜索结果网页
我正试图删除显示搜索结果的页面。我做了一个简单的刮刀,它可以工作,但当我尝试这个搜索页面时,应该显示搜索结果的地方会说:“我们找不到你要求的页面。如果你需要,请寻求帮助。”。 我怎样才能报废搜索的网页,以便我知道报废的结果会随着时间的推移而有所不同 我试过了 而我实际上是想放弃。 这是刮削的代码Java 抓取搜索结果网页,java,scraper,Java,Scraper,我正试图删除显示搜索结果的页面。我做了一个简单的刮刀,它可以工作,但当我尝试这个搜索页面时,应该显示搜索结果的地方会说:“我们找不到你要求的页面。如果你需要,请寻求帮助。”。 我怎样才能报废搜索的网页,以便我知道报废的结果会随着时间的推移而有所不同 我试过了 而我实际上是想放弃。 这是刮削的代码 try { Connection connection = Jsoup.connect(url).userAgent(USER_AGENT); Docum
try
{
Connection connection = Jsoup.connect(url).userAgent(USER_AGENT);
Document htmlDocument = connection.get();
this.htmlDocument = htmlDocument;
String qqq=htmlDocument.toString();
System.out.println(qqq);
if(connection.response().statusCode() == 200) // 200 is the HTTP OK status code
// indicating that everything is great.
{
System.out.println("\n**Visiting** Received web page at " + url);
}
if(!connection.response().contentType().contains("text/html"))
{
System.out.println("**Failure** Retrieved something other than HTML");
return false;
}
Elements linksOnPage = htmlDocument.select("a[href]");
System.out.println("Found (" + linksOnPage.size() + ") links");
for(Element link : linksOnPage)
{
this.links.add(link.absUrl("href"));
System.out.println(link.absUrl("href"));
}
return true;
}
catch(IOException ioe)
{
// We were not successful in our HTTP request
return false;
}
请发布您的代码、输入示例和实际错误。你的问题太模糊了…我编辑了网页和代码。谢谢