List<HTMLNode> removes = new ArrayList<HTMLNode>();
NodeIterator nodeIterator = root.iterator();
// System.out.println(new String(first.getValue()));
while(nodeIterator.hasNext()) {
HTMLNode node = nodeIterator.next();
switch (node.getName()) {
case UL:
if(isLinkContainer(node)) removes.add(node);
break;
case DIV:
case TD:
if(isLinkDiv(node)) removes.add(node);
break;
case CONTENT:
// System.out.println(new String(iterNode.getValue()));
if(node == first) remove = false;
if(remove) {
removes.add(node);
// System.out.println(new String(node.getValue()));
}
if(node == last) remove = true;
break;
default:
break;
}
}
// System.out.println(new String(last.getValue()));
for(int i = 0; i < removes.size(); i++) {
HTMLNode node = removes.get(i);
HTMLNode parent = node.getParent();
// System.out.println(parent.getTextValue());
while(parent != null) {
// System.out.println(parent.getTextValue());
node.setValue(new char[]{});
parent.removeChild(node);
int word = countWord(parent);
if(word > 15) break;
node = parent;
parent = node.getParent();