List of usage examples for org.jsoup.nodes Node equals
@Override public boolean equals(Object o)
From source file:net.poemerchant.scraper.ShopScraper.java
public List<Buyout> scrapeItemBuyouts(int noOfItems) { buyouts = new ArrayList<Buyout>(noOfItems); for (int i = 0; i < noOfItems; i++) { Buyout buyout = Buyout.NONE;// w w w . j a v a 2 s . c o m Node itemElem = doc.select("#item-fragment-" + i).first(); Element itemElemNext = doc.select("#item-fragment-" + (i + 1)).first(); if (itemElem != null) { while (!itemElem.equals(itemElemNext)) { itemElem = itemElem.nextSibling(); if (itemElem == null) { // case where there is no b/o set and we've reached the end of a spoiler break; } if (Element.class.isAssignableFrom(itemElem.getClass())) continue; String boRaw = StringUtils.trim(itemElem.toString()); String[] split = StringUtils.split(boRaw); if (split.length == 3) { BuyoutMode buyoutMode = BuyoutMode.parse(split[0]); if (buyoutMode != BuyoutMode.unknown) { buyout = new Buyout(boRaw); break; } } } } else { logger.severe( "Actual item in the OP was not found. Buyout will be defaulted to NONE. Item index is " + i); } buyouts.add(buyout); } return buyouts; }
From source file:sk.svec.jan.acb.extraction.Finder.java
public Node removeNodes(Node root, Node nodeToRemove) { Node node = root; Node ntr = nodeToRemove;/*from w w w. ja va2s . c om*/ int depth = 0; while (node != null) { if (node.equals(ntr)) { node.remove(); return root; } if (node.childNodeSize() > 0) { node = node.childNode(0); depth++; } else { while (node.nextSibling() == null && depth > 0) { node = node.parentNode(); depth--; } if (node == root) { break; } node = node.nextSibling(); } } return root; }