Package org.jsoup.select

Examples of org.jsoup.select.Elements.first()


    }

    private void appendMacroBody(StringBuilder builder, Element element) {
        Elements bodies = element.getElementsByTag("ac:rich-text-body");
        if (!bodies.isEmpty()) {
            Element body = bodies.first();
            cleanNodes(body, "div");
            cleanNodes(body, "p");
            builder.append(body.text().replaceAll("<br/>", "\n")).append("\n");
        }
    }
View Full Code Here


    protected void addExamples(Document doc, StringBuilder builder) {
        Elements tables = doc.getElementsByTag("table");
        if (!tables.isEmpty()) {
            builder.append("Examples:\n");
            Element table = tables.first();
            Elements headers = table.select("tr").first().select("th");
            for (Element header : headers) {
                builder.append("|").append(header.text());
            }
            builder.append("|\n");
View Full Code Here

 
  // Geo information
  Elements tweet_loc = doc.select("a.tweet-geo-text");
  if (!tweet_loc.isEmpty()) {
      JsonObject location = new JsonObject();
      Element loc = tweet_loc.first();
      // Adding http to avoid malformed URL exception
      URL url = new URL("http:" + loc.attr("href"));
      Map<String, String> query_params = HTMLStatusExtractor.splitQuery(url);
      // Loop over possible query parameters
      // http://asnsblues.blogspot.ch/2011/11/google-maps-query-string-parameters.html
View Full Code Here

  private Account addAccountDetails(Account pAccount, Document pDocument) {
    Elements vAccountDetails = pDocument
        .select("strong:contains(Saldo och transaktioner) ~ table")
        .first().select("tr td:last-child");
    String vAccountType = vAccountDetails.first().text();
    String vBalance = vAccountDetails.last().text();
    pAccount.setName(vAccountType);
    pAccount.setCurrency(Currency.getInstance("SEK"));
    BigDecimal balance = new BigDecimal(vBalance.replaceAll("[^\\d]", ""));
    pAccount.setBalance(balance);
View Full Code Here

            .setDescription(vTransaction.getAmount().compareTo(BigDecimal.ZERO) > 0 ? "Insättning"
                : "Uttag");
      }
      vTransaction.setCurrency(Currency.getInstance("SEK"));

      vTransaction.setTransactionDate(new LocalDate(vTransactionElement.first().text()));
      vTransactions.add(vTransaction);
    }
    return vTransactions;
  }
View Full Code Here

      Elements e = doc.getElementsByTag("div");
      Elements divInhaltElements = e.select("#inhalt");
      if (divInhaltElements == null || divInhaltElements.size() == 0) {
        System.out.println("no div with id=\"inhalt\"!");
      } else {
        Element divInhalt = divInhaltElements.first();
        result = parseContent(divInhalt);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
View Full Code Here

        } else {
            try {
                Elements elements = doc.select("div.mw-content-ltr > p");

                if (elements.size() > 0) {
                    Element p = elements.first();
                    String summary = p.text();

                    channel.write(url.toString());
                    channel.writeMultiple(BotAppletUtil.blockFormat(summary, 400, 10));
                } else {
View Full Code Here

    public Element wrap(String html) {
        Validate.notEmpty(html);

        Element wrapBody = Parser.parseBodyFragmentRelaxed(html, baseUri).body();
        Elements wrapChildren = wrapBody.children();
        Element wrap = wrapChildren.first();
        if (wrap == null) // nothing to wrap with; noop
            return null;

        Element deepest = getDeepChild(wrap);
        parentNode.replaceChild(this, wrap);
View Full Code Here

    }

    // merge multiple <head> or <body> contents into one, delete the remainder, and ensure they are owned by <html>
    private void normaliseStructure(String tag, Element htmlEl) {
        Elements elements = this.getElementsByTag(tag);
        Element master = elements.first(); // will always be available as created above if not existent
        if (elements.size() > 1) { // dupes, move contents to master
            List<Node> toMove = new ArrayList<Node>();
            for (int i = 1; i < elements.size(); i++) {
                Node dupe = elements.get(i);
                for (Node node : dupe.childNodes)
View Full Code Here

    }

    // merge multiple <head> or <body> contents into one, delete the remainder, and ensure they are owned by <html>
    private void normaliseStructure(String tag, Element htmlEl) {
        Elements elements = this.getElementsByTag(tag);
        Element master = elements.first(); // will always be available as created above if not existent
        if (elements.size() > 1) { // dupes, move contents to master
            List<Node> toMove = new ArrayList<Node>();
            for (int i = 1; i < elements.size(); i++) {
                Node dupe = elements.get(i);
                for (Node node : dupe.childNodes)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.