Package org.jsoup.select

Examples of org.jsoup.select.Elements


    return new Index(children.indexOf(node), children.size());
  }

  @Override
  public Collection<? extends Node> getDescendentNodes(final Node node) {
    Elements descendents;
    if (node instanceof Document)
      descendents = ((Document)node).getAllElements();
    else
      descendents = ((Element)node).getAllElements();

    descendents.remove(node); // Jsoup includes the target of getAllElements() in the result...
    return descendents;
  }
View Full Code Here


  private List<MealInfo> parseMensaSite() {
    List<MealInfo> result = null;

    try {
      Document doc = Jsoup.connect(MENSA_URL_BASE).get();
      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

    // we only work Monday through Friday
    if (day < 0 || day > 4)
      return result;

    try {
      Elements allTD = divInhalt.getElementsByTag("td");
      Elements allMeals = allTD
          .select("[class~=(schrift_gerichte|schrift_spezial)]");

      int mealDay = 0;
      int line = 1;
      int id = 0;
      for (int i = 0; i < allMeals.size(); i++) {
        if (allMeals.get(i).text().startsWith("="))
          break;

        if (mealDay == day) {
          System.out
              .print((line % 2) == 1 ? (allMeals.get(i).text() + ": ")
                  : (allMeals.get(i).text() + "\n"));

          if ((line % 2) == 1) {
            MealInfo meal = new MealInfo();
            meal.id = id++;
            meal.name = allMeals.get(i).text();
            result.add(meal);
          } else {
            double price = searchDouble(allMeals.get(i).text(), 0);
            result.get(result.size() - 1).price = price;
          }
        }

        if (mealDay == 4)
View Full Code Here

                JMeterContextService.getContext().getSamplerContext().put(CACHE_KEY_PREFIX+cacheKey, document);
            }
        } else {
            document = Jsoup.parse(inputString);
        }
        Elements elements = document.select(expression);
        int size = elements.size();
        for (int i = 0; i < size; i++) {
            Element element = elements.get(i);
            if (matchNumber <=0 || found != matchNumber) {
                result.add(extractValue(attribute, element));
                found++;
            } else {
                break;
View Full Code Here

            return cachedValue;
        }
        try {
            String onPto = "";
            Document doc = Jsoup.connect(link).ignoreContentType(true).get();
            Elements titles = doc.select("rss channel item title");
            for (Element title : titles) {
                onPto += doNotNotify(title.text()) + ", ";
            }
            if (!onPto.isEmpty()) {
                String value = doNotNotify(onPto.substring(0, onPto.length() - 2));
View Full Code Here

      }
      obj.setSource(source);

      // thumb image
      Elements elements = doc.select("img");
      String thumb = "/images/thumb.png";
      String ct = doc.select("body").html().trim();
      if (elements.size() > 0) {
        for (int i = 0; i < elements.size(); i++) {
          ct = ct.replace(elements.get(i).toString(),
              "<div class='image'>" + elements.get(i).toString()
                  + "</div>");
        }
        thumb = elements.get(0).attr("src");
      }
      obj.setThumb(thumb);

      // tag
      String strTag = StringHelper.keyword(doc.text());
View Full Code Here

  public List<News> recoverListNews() {
    List<News> result = new ArrayList<News>();
    try {
      Document doc = Jsoup.parse(this.getStrListNews());
      Elements tmp;
      tmp = doc.select("news");
      for (Element element : tmp) {
        News obj = new News();
        obj.setAlias(element.select("alias").text());
        obj.setTitle(element.select("title").text());
View Full Code Here

        assertEquals( "Response", HttpServletResponse.SC_OK, response.getStatusCode() );

        List<String> expectedLinks = Arrays.asList( "../", "apache/", "codehaus/" );

        Document document = Jsoup.parse( response.getContentAsString() );
        Elements elements = document.getElementsByTag( "a" );

        assertLinks( expectedLinks, elements );
    }
View Full Code Here

        // dumpResponse( response );

        List<String> expectedLinks = Arrays.asList( ".indexer/", "commons-lang/", "net/", "org/" );

        Document document = Jsoup.parse( response.getContentAsString() );
        Elements elements = document.getElementsByTag( "a" );

        assertLinks( expectedLinks, elements );
    }
View Full Code Here

        // replace all links !!
        Document document = Jsoup.parse( is, "UTF-8", "" );

        Element body = document.body().child( 0 );

        Elements links = body.select( "a[href]" );

        for ( Element link : links ) {
            link.attr( "href", "#" + startPath + "/" + link.attr( "href" ) );
        }

        Elements codes = body.select( "code" );

        for ( Element code : codes ) {
            code.attr( "class", code.attr( "class" ) + " nice-code" );
        }

        //default generated enunciate use h1/h2/h3 which is quite big so transform to h3/h4/h5

        Elements headers = body.select( "h1" );

        for ( Element header : headers ) {
            header.tagName( "h3" );
        }
View Full Code Here

TOP

Related Classes of org.jsoup.select.Elements

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.