Package org.jsoup.nodes

Examples of org.jsoup.nodes.Document


  public List<Account> getAccounts() {
    BankRequest pRequest = new BankRequest().setUri(ACCOUNTS_URL)
        .setParams(getAccountsRequestParams());
    BankResponse response = mBankClient.post(pRequest);

    Document doc = Jsoup.parse(response.body());
    List<Account> accounts = parseAccounts(doc);

    if (!accounts.isEmpty()) {
      Account firstAccount = accounts.get(0);
      // Get account details for first account
View Full Code Here


    return "balanceForm:" + vId;
  }

  private List<Transaction> parseTransactions(String pResponse) {
    List<Transaction> vTransactions = new ArrayList<Transaction>();
    Document doc = Jsoup.parse(pResponse);
    Elements vTransactionElements =
        doc.getElementById("balanceForm:transactionPostList").select("tbody tr");

    for (Element element : vTransactionElements) {
      Transaction vTransaction = new Transaction();
      Elements vTransactionElement = element.select("td");
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();
View Full Code Here

     */
    @Override
    public int extract(String expression, String attribute, int matchNumber,
            String inputString, List<String> result, int found,
            String cacheKey) {
        Document document = null;
        if (cacheKey != null) {
            document = (Document)
                    JMeterContextService.getContext().getSamplerContext().get(CACHE_KEY_PREFIX+cacheKey);
            if(document==null) {
                document = Jsoup.parse(inputString);
                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));
View Full Code Here

    @Override
    public Iterator<URL> getEmbeddedResourceURLs(byte[] html, URL baseUrl,
            URLCollection coll, String encoding) throws HTMLParseException {
        try {
            String contents = new String(html,encoding);
            Document doc = Jsoup.parse(contents);
            JMeterNodeVisitor nodeVisitor = new JMeterNodeVisitor(new URLPointer(baseUrl), coll);
            new NodeTraversor(nodeVisitor).traverse(doc);
            return coll.iterator();
        } catch (Exception e) {
            throw new HTMLParseException(e);
View Full Code Here

    }

    public static String onSupport1() {
        // the simplest way of accessing the publicly available gdoc (OAuth is not needed here)
        String url = "https://docs.google.com/spreadsheet/pub?key=0AsqiOfOdbEhBdEtMZGRGUTVZNTNmYXlFdllqdU9Oamc&single=true&gid=1&output=txt";
        Document doc = null;
        try {
            doc = Jsoup.connect(url).get();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return doc.body().html().trim();
    }
View Full Code Here

        if (cachedValue != null) {
            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

      // title + alias
      obj.setTitle(title);
      obj.setAlias(StringHelper.replaceVietnamese(title));

      // category + category Alias
      Document doc = Jsoup.parse(content);
      if (category.equals("")) {
        obj.setCategory("Uncategory");
        obj.setCategoryAlias("uncategory");
      } else {
        category = category.replaceAll(",[\\w\\W]$", "");
        String cateAlias = StringHelper.replaceVietnamese(category);
        Category cate = CategoryModel.getById(cateAlias);
        if (cate == null) {
          cate = new Category();
          cate.setTitle(category);
          cate.setAlias(cateAlias);
          cate.setLevel(1);
          cate.setParentAlias("");
          cate.setDescription("");
          CategoryModel.insert(cate);
        }
        obj.setCategory(cate.getTitle());
        obj.setCategoryAlias(cate.getAlias());
      }

      // source
      String source = "";
      try {
        source = doc.select("a").last().attr("href");
      } catch (Exception e) {

      }
      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());
      try {
        ArrayList<String> listTag = new ArrayList<String>();
        String[] splitTag = strTag.split(",");
        for (String string : splitTag) {
          String tagAlias = StringHelper.replaceVietnamese(string
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());
        obj.setThumb(element.select("thumb").text());
View Full Code Here

    @Override
    public Iterator<URL> getEmbeddedResourceURLs(byte[] html, URL baseUrl,
            URLCollection coll, String encoding) throws HTMLParseException {
        try {
            String contents = new String(html,encoding);
            Document doc = Jsoup.parse(contents);
            JMeterNodeVisitor nodeVisitor = new JMeterNodeVisitor(new URLPointer(baseUrl), coll);
            new NodeTraversor(nodeVisitor).traverse(doc);
            return coll.iterator();
        } catch (Exception e) {
            throw new HTMLParseException(e);
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.