if (!aliasesStart.isEmpty()) { for (String text : aliasesStart) { cardsImages.addAll(doc.select("img[src^=" + text + ']'));
private Scope(Elements context){ super(); this.context = new Elements(); this.context.addAll(context); } private Scope(Element context){
private Scope(Elements context){ super(); this.context = new Elements(); this.context.addAll(context); } private Scope(Element context){
public Elements getElements() { Elements elements = new Elements(); for (XElements xElements : elementsList) { elements.addAll(xElements.getElements()); } return elements; }
@Override public XValue apply(Elements context) { Set<Element> total = new HashSet<>(); Elements ancestor = new Elements(); for (Element el:context){ total.addAll(el.parents()); //include self total.add(el); } ancestor.addAll(total); return XValue.create(ancestor); } }
public Elements getElements() { Elements elements = new Elements(); for (XElements xElements : elementsList) { elements.addAll(xElements.getElements()); } return elements; }
@Override public XValue apply(Elements context) { Set<Element> total = new HashSet<>(); Elements descendant = new Elements(); for (Element el:context){ Elements tmp = el.getAllElements(); total.addAll(tmp); } descendant.addAll(total); return XValue.create(descendant); } }
@Override public XValue apply(Elements context) { Set<Element> total = new HashSet<>(); Elements parents = new Elements(); for (Element el:context){ total.add(el.parent()); } parents.addAll(total); return XValue.create(parents); } }
@Override public XValue apply(Elements context) { Set<Element> total = new HashSet<>(); Elements ancestor = new Elements(); for (Element el:context){ total.addAll(el.parents()); } ancestor.addAll(total); return XValue.create(ancestor); } }
@Override public XValue apply(Elements context) { Set<Element> total = new HashSet<>(); Elements descendant = new Elements(); for (Element el:context){ Elements tmp = el.getAllElements(); total.addAll(tmp); } descendant.addAll(total); return XValue.create(descendant); } }
@Override public XValue apply(Elements context) { List<Element> total = new LinkedList<>(); Elements parents = new Elements(); for (Element el:context){ total.add(el.parent()); } parents.addAll(total); return XValue.create(parents); } }
/** * Get all the elements matching one of the given tags. * * @param tagNames tag names to match * @return the list of matching tags */ public Elements getElements(Collection<String> tagNames) { Elements elements = new Elements(); for (String tagName : tagNames) { elements.addAll(this.html5Document.getElementsByTag(tagName)); } return elements; }
public static void main(String[] args) throws IOException { Document doc = Jsoup.connect("http://www.fidalservizi.it/risultati/Izmir_2014/Gara053.htm").get(); Elements table = doc.select("tr:gt(0)").not("td#t1_ckrs.td_fine"); for (Element row : table) { if (isDataRow(row)) { System.out.print(" Pos :" + row.getElementById("t1_clas").text()); System.out.print(" Name :" + row.getElementById("t1_atle").text()); System.out.println(" Country " + row.getElementById("t1_soci").text()); } } } private static boolean isDataRow(Element row){ Elements elements = row.select("tr.due"); elements.addAll(row.select("tr.uno")); return !elements.isEmpty() && !elements.text().equalsIgnoreCase(""); }
@Override public XValue apply(Elements context) { Set<Element> total = new HashSet<>(); Elements descendant = new Elements(); for (Element el:context){ Elements tmp = el.getAllElements(); //exclude self tmp.remove(el); total.addAll(tmp); } descendant.addAll(total); return XValue.create(descendant); } }
@Override public XValue apply(Elements context) { Set<Element> total = new HashSet<>(); Elements descendant = new Elements(); for (Element el:context){ Elements tmp = el.getAllElements(); //exclude self tmp.remove(el); total.addAll(tmp); } descendant.addAll(total); return XValue.create(descendant); } }
@Override public XValue apply(Elements context) { Elements childs = new Elements(); for (Element el:context){ childs.addAll(el.children()); } return XValue.create(childs); } }
@Override public XValue apply(Elements context) { Elements childs = new Elements(); for (Element el:context){ childs.addAll(el.children()); } return XValue.create(childs); } }
@Override public XValue visitAbbreviatedStep(XpathParser.AbbreviatedStepContext ctx) { if ("..".equals(ctx.getText())){ Set<Element> total = new HashSet<>(); Elements newContext = new Elements(); for (Element e:currentScope().context()){ total.add(e.parent()); } newContext.addAll(total); return XValue.create(newContext); }else { return XValue.create(currentScope().context()); } }
@Override public XValue visitAbbreviatedStep(XpathParser.AbbreviatedStepContext ctx) { if ("..".equals(ctx.getText())){ Set<Element> total = new HashSet<>(); Elements newContext = new Elements(); for (Element e:currentScope().context()){ total.add(e.parent()); } newContext.addAll(total); return XValue.create(newContext); }else { return XValue.create(currentScope().context()); } }