Package org.jsoup.nodes

Examples of org.jsoup.nodes.Document


    ////////////////////
    //On se connecte au site et on charge le document html
    Connection connection = Jsoup.connect(urlServer);
    connection.timeout(30*1000); //in miliseondes
   
    Document doc = connection.url(urlServer).get();
   
    //On récupère dans ce document la premiere balise ayant comme nom h1 et pour attribut class="title"
    Elements elements= doc.getElementsByClass("boxStats");
   
    //Voir aussi si on peut ajouter le WN8 des joueurs
    //http://wotlabs.net/eu/player/strong44
    /*
     * <div class="boxStats boxWn green" style="width:18%;float:left;margin-right:2.5%;margin-bottom:25px;">
View Full Code Here


        final JSONObject data = event.getData();
        final JSONObject article = data.optJSONObject(Article.ARTICLE);

        String content = article.optString(Article.ARTICLE_CONTENT);

        final Document doc = Jsoup.parse(content);

        final StringBuilder listBuilder = new StringBuilder();

        listBuilder.append("<link rel=\"stylesheet\" type=\"text/css\" href=\"" + Latkes.getStaticPath() + "/plugins/list/style.css\" />");

        final Elements hs = doc.select("h1, h2, h3, h4, h5");

        listBuilder.append("<ul class='b3-solo-list'>");
        for (int i = 0; i < hs.size(); i++) {
            final Element element = hs.get(i);
            final String tagName = element.tagName().toLowerCase();
            final String text = element.text();
            final String id = "b3_solo_" + tagName + "_" + i;

            element.before("<span id='" + id + "'></span>");

            listBuilder.append("<li class='b3-solo-list-").append(tagName).append("'><a href='#").append(id).append("'>").append(text).append(
                "</a></li>");
        }
        listBuilder.append("</ul>");

        final Element body = doc.getElementsByTag("body").get(0);

        content = listBuilder.toString() + body.html();

        article.put(Article.ARTICLE_CONTENT, content);
    }
View Full Code Here

            sink.sectionTitle1();
          sink.text( bundle.getString( "report.fitnesse.name" ) );
          sink.sectionTitle1_();
      for(String report : reports) {
                //String html = html(report);
                Document document = Jsoup.parse(new File(this.reportsDir, report), null);
                Elements tables = document.getElementsByTag("table");
                // Is it a top-level index page?
                if(tables.size() == 1 &&
                    testTdElements(tables.get(0).getElementsByTag("td"), "name", "right", "wrong", "exceptions")) {
                     
                  Elements hrefs = document.getElementsByTag("a");
                  for(Element href : hrefs) {
                    String extant = href.attr("href");
                    href.attr("href", OUTPUT_NAME + "." + extant);
                  }
                    sink.rawText(document.html());
          /*
                  if(!styleDone) {
                        addElements(sink, document.head().getElementsByTag("link"));
                        addElements(sink, document.head().getElementsByTag("script"));
                        styleDone = true;
View Full Code Here

 
  private void logExceptions() throws MojoExecutionException {
        final Launch[] launches = super.launches();
        for(int i = 0 ; i < launches.length && logErrorsToConsole() ; i++) {
          final File indexFile =  new File(this.reportsDir, launches[i].getPageName() + HTML);
          final Document indexHtml = parseHtml(indexFile);
          final List<Element> anchors = indexHtml.getElementsByTag("a");
          for(int j = 0 ; j < anchors.size() && logErrorsToConsole() ; j++) {
            final String test = anchors.get(j).attr("href");
              final File testFile =  new File(this.reportsDir, test);
              final Document testHtml = parseHtml(testFile);
              final List<Element> errors = testHtml.getElementsByClass("error");
              for(int k = 0 ; k < errors.size() && logErrorsToConsole() ; k++) {
                final Element error = errors.get(k);
                final Elements fitLabel = error.getElementsByClass("fit_label");
                if(!fitLabel.isEmpty()) {
                  logFitNesseError(test, fitLabel.text());
                }
                final Elements fitStacktrace = error.getElementsByClass("fit_stacktrace");
                if(!fitStacktrace.isEmpty()) {
                  logFitNesseError(test, fitStacktrace.text());
                }
              }
              final List<Element> details = testHtml.getElementsByClass("exception-detail");
              for(int k = 0 ; k < details.size() && logErrorsToConsole() ; k++) {
                final Element detail = details.get(k);
                if(detail.hasText()) {
                  logFitNesseError(test, StringUtils.substringAfter(detail.text(), SlimServer.EXCEPTION_TAG));
                }
View Full Code Here

    }
  }
 
  private Document parseHtml(final File file) throws MojoExecutionException {
         try {
          final Document html = Jsoup.parse(file, ReaderFactory.UTF_8);
      return html;
    } catch (final IOException e) {
      throw new MojoExecutionException("IOException: " + file, e);
    } finally {
      // JSoup closes the stream for us
View Full Code Here

    }
    return content.toString();
  }

  public void transformString(String channelString) {
    Document doc = Jsoup.parse(channelString);
    Elements tmp;
    tmp = doc.select("alias");
    if (tmp != null) {
      this.alias = (tmp.text());
    }
    tmp = doc.select("thumbImageUrl");
    if (tmp != null) {
      this.thumbImageUrl = (new Text(tmp.text()));
    }
    tmp = doc.select("title");
    if (tmp != null) {
      this.title = (new Text(tmp.text()));
    }
  }
View Full Code Here

        root.put("entityName", entityName);
        root.put("property", voucherProperties);
        Resource<URL> templateResource = resourceFactory.create(getClass().getResource(Deployments.BASE_PACKAGE_PATH + Deployments.N_TO_ONE_PROPERTY_DETAIL_INCLUDE));
        Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
        String output = processor.process(root);
        Document html = Jsoup.parseBodyFragment(output);
        assertThat(output.trim(), not(equalTo("")));

        Elements container = html.select("div.form-group");
        assertThat(container, notNullValue());
        assertThat(container.attr("ng-class"), not(equalTo("")));

        Elements oneToOneWidgetElement = html.select("div.form-group > div.col-sm-10");
        assertThat(oneToOneWidgetElement, notNullValue());

        Elements selectElement = oneToOneWidgetElement.select(" > select");
        assertThat(selectElement, notNullValue());
        assertThat(selectElement.attr("id"), equalTo(oneToOneProperty));
View Full Code Here

        root.put("entityName", entityName);
        root.put("property", customerProperties);
        Resource<URL> templateResource = resourceFactory.create(getClass().getResource(Deployments.BASE_PACKAGE_PATH + Deployments.N_TO_ONE_PROPERTY_DETAIL_INCLUDE));
        Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
        String output = processor.process(root);
        Document html = Jsoup.parseBodyFragment(output);
        assertThat(output.trim(), not(equalTo("")));

        Elements container = html.select("div.form-group");
        assertThat(container, notNullValue());
        assertThat(container.attr("ng-class"), not(equalTo("")));

        Elements oneToOneWidgetElement = html.select("div.form-group > div.col-sm-10");
        assertThat(oneToOneWidgetElement, notNullValue());

        Elements selectElement = oneToOneWidgetElement.select(" > select");
        assertThat(selectElement, notNullValue());
        assertThat(selectElement.attr("id"), equalTo(oneToOneProperty));
View Full Code Here

        Map<String, Object> root = TestHelpers.createInspectionResultWrapper(ENTITY_NAME, BASIC_STRING_PROP);

        Resource<URL> templateResource = resourceFactory.create(getClass().getResource(Deployments.BASE_PACKAGE_PATH + Deployments.SEARCH_FORM_INPUT));
        Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
        String output = processor.process(root);
        Document html = Jsoup.parseBodyFragment(output);
        assertThat(output.trim(), not(equalTo("")));

        Elements container = html.select("div.form-group");
        assertThat(container, notNullValue());

        Elements formInputElement = container.select("div.col-sm-10 > input");
        assertThat(formInputElement.attr("id"), equalTo("fullName"));
        assertThat(formInputElement.attr("type"), equalTo("text"));
View Full Code Here

        Map<String, Object> root = TestHelpers.createInspectionResultWrapper(ENTITY_NAME, NUMBER_PROP);

        Resource<URL> templateResource = resourceFactory.create(getClass().getResource(Deployments.BASE_PACKAGE_PATH + Deployments.SEARCH_FORM_INPUT));
        Template processor = processorFactory.create(templateResource, FreemarkerTemplate.class);
        String output = processor.process(root);
        Document html = Jsoup.parseBodyFragment(output);
        assertThat(output.trim(), not(equalTo("")));

        Elements container = html.select("div.form-group");
        assertThat(container, notNullValue());

        Elements formInputElement = container.select("div.col-sm-10 > input");
        assertThat(formInputElement.attr("id"), equalTo("score"));
        assertThat(formInputElement.attr("type"), equalTo("text"));
View Full Code Here

TOP

Related Classes of org.jsoup.nodes.Document

Copyright © 2018 www.massapicom. 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.