尽管它很简单并且已经提出了类似的问题,但我不知何故无法解决它。
public static Document removeDiv(Document document){
document.getElementById("Wrapper_FixedWidth_Footer").remove();
document.getElementById("u01").remove();
return document;
}`
请使用以下文档作为该方法的输入。
Document doc = Jsoup.connect("https://www.oracle.com/storage/san/fs1/index.html").ignoreHttpErrors(true).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0").timeout(0).get();
更具体地说,我不想包含页眉和页脚。 (我不想要本文档页眉和页脚相应div下的链接)
最佳答案
问题已解决。我在代码的其他部分检查的爬虫和条件似乎存在一些问题。
关于java - 使用 JSoup 解析文档并删除具有特定 ID 和类的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32532943/