我想搜索结果。但是我得到null
。
我的代码:
public class Example{
public static void main(String[] args) {
String searchQuery = "Лукашенко";
WebClient client = new WebClient();
client.setJavaScriptEnabled(false);
HtmlPage page;
try {
String searchUrl = "http://search.tut.by/?status=1&ru=1&encoding=1&page=0&how=rlv&query=" + URLEncoder.encode(searchQuery, "windows-1251");
page = client.getPage(searchUrl);
System.out.println(page.getPage());
System.out.println(getByXPath("/html/body/div[3]/div/div[2]/div[2]/div/div[2]/ol/li[1]"));
List<HtmlElement> items = (List<HtmlElement>)
page.getByXPath("(.//li[@class=\"b-results__li\"])");
System.out.println(items.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
运行代码时,我得到:
HtmlPage(http://search.tut.by/?status=1&ru=1&encoding=1&page=0&how=rlv&query=%CB%F3%EA%E0%F8%E5%ED%EA%EE)@2039810346
[]
[]
BUILD SUCCESSFUL in 2s
2 actionable tasks: 2 executed
元素在哪里? 我检查了我的XPath。