wemagic java爬虫获取翻页的总页码问题

如图所示,怎么只获取最后一个?

https://img1.mukewang.com/5b4853120001976815320366.jpg

qq_花开花谢_0
浏览 627回答 2
2回答

弑天下

// 时间,多个span,只获取最后一个span的内容&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;List<String> t = page.getHtml()&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.xpath("//div[@class='article-sub']/span/text()").all();&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;List<String> time = Arrays.asList(t.get(t.size() - 1));

哈士奇WWW

WebElement web = webDriver.findElement(By.xpath("(//ul[@class='paging']/li)[last()-1]/a"));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String ys =web.getText();
打开App,查看更多内容
随时随地看视频慕课网APP