Esempio n. 1
1
 public Date getStartDate(StockInfo stock) throws Exception {
   String path = "/corp/go.php/vMS_MarketHistory/stockid/" + stock.numberToString() + ".phtml";
   URI uri =
       new URIBuilder()
           .setScheme("http")
           .setHost("vip.stock.finance.sina.com.cn")
           .setPath(path)
           .setParameter("year", "1980")
           .setParameter("jidu", "1")
           .build();
   DownloadHelper download = new DownloadHelper(uri);
   InputStream is = download.getInputStream();
   Document doc = Jsoup.parse(inputStreamToStringBuilder(is).toString());
   is.close();
   download.close();
   Elements select = doc.getElementsByAttributeValue("name", "year");
   if (select == null) {
     return null;
   }
   // System.out.println(select.size());
   Elements years = select.get(0).getElementsByTag("option");
   String year = years.get(years.size() - 1).text();
   // System.out.println(year);
   return Date.quarterToDate(Integer.parseInt(year), tryQuarter(stock, year));
 }
  private void initPane() {
    //		WebEngine engine = optionView.getEngine();
    try {
      Document document = Jsoup.connect(webView.getEngine().getLocation()).get();
      Element table =
          document.select("#normal_basket_" + document.select("[name=item_id]").val()).first();
      Element td = table.select("td").first();
      Elements spans = td.select("span");
      Elements selects = td.select("select");
      //			System.out.println(spans.size());
      cmb = new ArrayList<ComboBox>();
      for (int i = 0; i < spans.size(); i++) {

        ObservableList<ValuePair> obs = FXCollections.observableArrayList();
        Elements options = selects.get(i).select("option");
        for (int k = 0; k < options.size(); k++) {
          Element option = options.get(k);
          obs.add(new ValuePair("choice", option.text(), option.val()));
        }

        cmb.add(new ComboBox<ValuePair>(obs));
        optionArea.getChildren().addAll(new Text(spans.get(i).text()), cmb.get(i));
      }

    } catch (Exception e) {
      // TODO 自動生成された catch ブロック
      e.printStackTrace();
    }
  }
Esempio n. 3
0
  /**
   * Method responsible for querying and parsing to correios cep locator
   *
   * @author pulu - 09/09/2013
   */
  private Webservicecep findAddressByCepAtCorreios(String url) throws IOException {
    HttpClient httpClient = new HttpClient();
    PostMethod postMethod = new PostMethod(url);
    log.log(Level.INFO, "Querying to correios WS...");
    try {
      httpClient.executeMethod(postMethod);

      if (postMethod.getStatusCode() == HttpStatus.SC_OK) {
        Document doc = Jsoup.parse(new URL(url).openStream(), "ISO-8859-1", url);
        Elements elements = doc.select("td:not([colspan]):not(:has(*))");

        return new Webservicecep(
            Webservicecep.SUCCESS_CODE,
            elements.get(3).ownText(),
            elements.get(2).ownText(),
            elements.get(1).ownText(),
            "",
            elements.get(0).ownText());

      } else return new Webservicecep(Webservicecep.ERROR_CODE);
    } catch (Exception e) {
      log.log(Level.WARNING, "Failed to parse html data. Possible reason: invalid cep.");
      return new Webservicecep(Webservicecep.ERROR_CODE);
    }
  }
  @BeforeClass
  public static void setUp() {
    File input =
        new File("src/test/java/org/jenkinsci/plugins/marketfeaturereport/market_features.html");
    Document doc = null;
    try {
      doc = Jsoup.parse(input, "UTF-8");
    } catch (IOException e) {
      e.printStackTrace();
    }
    assert doc != null;
    Element content = doc.getElementById("market-feature-header");
    Elements header = content.getElementsByClass("rTableHead");
    Elements failedHeader = content.getElementsByClass("rTableHeadFailed");
    Elements rows = content.getElementsByClass("rTableCell");
    Elements rows_failed = content.getElementsByClass("rTableCellFailed");
    int count_failed = 0, count = 0;

    for (Element element : header) {
      summary_table.put(element.text(), rows.get(count).text());
      ++count;
    }
    Elements link_error = content.getElementsByTag("a");
    for (Element element : failedHeader) {
      summary_table.put(element.text(), rows_failed.get(count_failed).text());
      String linkHref = link_error.get(count_failed).attr("href");
      summary_error_table.put(element.text(), linkHref);
      ++count_failed;
    }
  }
  /**
   * 解析数据,默认解析第一列
   *
   * @param rows 源数据集
   * @return 节目数据
   */
  private static String[][] parseRows(Elements rows) {
    String[][] programs = new String[rows.size()][2];
    int rowspan_0 = 0;
    int rowspan_1 = 0;
    for (int i = 0; i < rows.size(); i++) {
      Element row = rows.get(i);
      try {
        Elements cells = row.children();

        if (rowspan_0 == 0) {
          Element cell_0 = cells.get(0);
          rowspan_0 = Integer.valueOf(cell_0.attr("rowspan"));
          if (rowspan_1 == 0) {
            Element cell_1 = cells.get(1);
            rowspan_1 = Integer.valueOf(cell_1.attr("rowspan"));
            programs[i][0] = DBclass.xmlFilte(cell_1.select("dt").text());
            programs[i][1] = DBclass.xmlFilte(cell_1.select("dd").text());
          }
        } else if (rowspan_1 == 0) {
          Element cell_0 = cells.get(0);
          rowspan_1 = Integer.valueOf(cell_0.attr("rowspan"));
          programs[i][0] = DBclass.xmlFilte(cell_0.select("dt").text());
          programs[i][1] = DBclass.xmlFilte(cell_0.select("dd").text());
        }
        rowspan_0--;
        rowspan_1--;
      } catch (Exception e) {
        e.printStackTrace(System.out);
      }
    }
    return programs;
  }
  @Override
  protected void initialize(Element source) {
    Elements elements = source.getElementsByTag("td");

    Element element = elements.get(0).select("[data-sc-params]").get(0);
    String name =
        element
            .attr("data-sc-params")
            .replaceAll("\\{ 'name': '", "")
            .replaceAll("', 'magnet':.*", "")
            .replaceAll("%20", "\\.")
            .replaceAll("%5B.*", "");

    ShowData showData = ShowData.fromFilename(name);
    initialize(showData);

    seeds = Integer.parseInt(elements.get(4).text());
    peers = Integer.parseInt(elements.get(5).text());

    element = elements.get(0).select("div a[title=Download torrent file]").get(0);
    String[] array = element.attr("href").split("\\?");
    downloadLink = array[0].replaceAll("\\.torrent", "/temp\\.torrent");

    if (downloadLink.startsWith("//")) {
      downloadLink = "http:" + downloadLink;
    }
  }
Esempio n. 7
0
 private static void parseStatHeaderDetails(Document doc, Statistic stat) {
   Elements statsTrs = doc.select("table#id_stats").select("tr");
   for (Element tr : statsTrs) {
     Elements tds = tr.select("td");
     String name = tds.get(0).text().trim();
     String value = tds.get(1).text().trim();
     if (name != null) {
       if (name.startsWith("Win-Loss-Void")) {
         String[] values = value.split("-");
         if (values != null && values.length == 3) {
           stat.setWin(NumberParser.parseInt(values[0]));
           stat.setLose(NumberParser.parseInt(values[1]));
           stat.setVoid_(NumberParser.parseInt(values[2]));
         } else {
           logger.warn("Win-Loss-Void section doesn't contain 3 elements as expected");
         }
       } else if (name.startsWith("Stake avg")) {
         stat.setAvgStake(NumberParser.parseDouble(value));
       } else if (name.startsWith("Odd avg")) {
         stat.setAvgOdds(NumberParser.parseDouble(value));
       } else if (name.startsWith("Staked")) {
         stat.setStaked(NumberParser.parseDouble(value));
       } else if (name.startsWith("Returned")) {
         stat.setReturned(NumberParser.parseDouble(value));
       }
     }
   }
 }
  /**
   * ****************************************************************** Constructor:
   * CurrentGradeDetail Purpose: create a grade detail object Parameters: Element gradeDetail:
   * contains HTML grade information
   * /******************************************************************
   */
  public CurrentGradeItem(Elements gradeDetail) {

    // 6 Children?
    if (gradeDetail.size() >= 6) {

      // Set properties
      this.gradeName = gradeDetail.get(0).text();
      this.validGrade = true;

      // Score

      this.score = gradeDetail.get(5).text();

      // Points Possible
      this.pointsPossible = gradeDetail.get(6).text();
    }

    // Not enough children
    else {
      this.validGrade = false;
      this.gradeName = "error";
      this.score = "";
      this.pointsPossible = "";
    }
  }
Esempio n. 9
0
  private void processEntry(
      @NotNull String queryString,
      @NotNull Element entryNode,
      @NotNull BilingualQueryResultBuilder resultBuilder,
      @NotNull Language sourceLanguage,
      @NotNull Language targetLanguage) {
    if (!StringUtils.equals(entryNode.tag().getName(), "tr")) {
      LOGGER.warn("Expected <tr> tag - got <{}>", entryNode.tag().getName());
      return;
    }
    Elements words = entryNode.getElementsByClass("words");

    if (words.size() != 2) {
      LOGGER.warn("Expected 2 elements with class \"words\" - got {}", words.size());
      return;
    }

    BilingualEntryBuilder entryBuilder = ImmutableBilingualEntry.builder();

    entryBuilder.setEntryType(detectEntryType(words.get(0)));
    entryBuilder.setInputObject(processSingleNode(words.get(0), sourceLanguage, queryString));
    entryBuilder.setOutputObject(processSingleNode(words.get(1), targetLanguage, queryString));

    resultBuilder.addBilingualEntry(entryBuilder.build());
  }
Esempio n. 10
0
 public List<AreaVO> parseMessage(String text, int pid) {
   Document doc = Jsoup.parse(text);
   Element body = doc.body();
   List<AreaVO> areas = new ArrayList<AreaVO>();
   Elements divs = body.getElementsByClass("subarea");
   if (divs.size() > 0) {
     Element div = divs.get(0);
     Elements childs = div.children();
     String letter = "";
     for (int i = 1; i < childs.size(); i++) {
       Element child = childs.get(i);
       if ("b".equals(child.tagName())) {
         letter = child.text();
         continue;
       }
       if ("a".equals(child.tagName())) {
         AreaVO area = new AreaVO();
         area.setLetter(letter);
         area.setName(child.text());
         area.setOrderIdx(index);
         area.setPid(pid);
         String href = child.attr("href");
         String pinyin = href.substring(7, href.lastIndexOf("/"));
         area.setPinyin(pinyin);
         index++;
         System.out.println(area.toString());
         areas.add(area);
       }
     }
   }
   return areas;
 }
Esempio n. 11
0
 @Test
 public void testElementSiblingIndexSameContent() {
   Document doc = Jsoup.parse("<div><p>One</p>...<p>One</p>...<p>One</p>");
   Elements ps = doc.select("p");
   assertTrue(0 == ps.get(0).elementSiblingIndex());
   assertTrue(1 == ps.get(1).elementSiblingIndex());
   assertTrue(2 == ps.get(2).elementSiblingIndex());
 }
Esempio n. 12
0
  private boolean isSecondModel(Elements headers) {
    // TODO Auto-generated method stub
    String distance = headers.get(2).text();
    String record = headers.get(7).text();

    if (distance.equals("Dist.") && record.equals("Record")) return true;
    else return false;
  }
  /**
   * 提取每一场演出的票价
   *
   * @param url 演出url
   */
  private void extractEach(String url) {
    Show show = new Show();
    try {
      show.setAgent_id(agentID);
      Document ticket = getDoc(url);
      show.setType(typeCor.get(ticket.select("a.font12hui_bottom:eq(2)").text().trim()));
      show.setName(ticket.select("td.PERFORM_BOLD_NAME").text()); // 演出标题
      // 演出简介
      show.setIntroduction(
          PubFun.cleanElement(ticket.select("body>table").get(6).select("table").get(3)).html());
      show.setSiteName(ticket.select(".font12hui:contains(演出场馆)").text().replace("演出场馆:", ""));
      show.setImage_path(ticket.select("img[width=240]").first().attr("abs:src"));

      Map<String, List<TicketPrice>> timeAndPrice = new HashMap<String, List<TicketPrice>>();
      show.setTimeAndPrice(timeAndPrice);
      for (Element each :
          ticket.select("body>table").get(6).select("table tr[id^=perform_price_line]")) {
        Elements tmp = each.select("td");
        String time = tmp.get(1).text();
        if (time.length() == 18) { // 正常时间
          time = time.substring(0, 16);
        }
        List<TicketPrice> ticketPrice = new ArrayList<TicketPrice>();
        timeAndPrice.put(time, ticketPrice);
        int priceIndex = 2;
        if (tmp.size() > 3) { // 含有套票
          String[] prices = tmp.get(priceIndex).select("span.font14lanse").text().split("\\s+");
          for (int i = 0; i < prices.length; i++) {
            Elements a =
                tmp.get(priceIndex).select("span.font14lanse a:matches(\\b" + prices[i] + "\\b)");
            TicketPrice price = new TicketPrice();
            price.setMainURL(url);
            price.setPrice(prices[i]);
            price.setExist(!a.isEmpty());
            if (price.isExist()) {
              price.setRemark(a.first().attr("title"));
            }
            ticketPrice.add(price);
          }
          priceIndex = 3;
        }
        String[] prices = tmp.get(priceIndex).select("span.font14lanse").text().split("\\s+");
        for (int i = 0; i < prices.length; i++) { // 正常的非套票
          Elements a =
              tmp.get(priceIndex).select("span.font14lanse a:matches(\\b" + prices[i] + "\\b)");
          TicketPrice price = new TicketPrice();
          price.setMainURL(url);
          price.setPrice(prices[i]);
          price.setExist(!a.isEmpty());
          ticketPrice.add(price);
        }
      }
      getDao().saveShow(show);
    } catch (Exception e) {
      log.error(url, e);
    }
  }
Esempio n. 14
0
  public Table(Elements spans, String workLocation, File file) throws IOException {
    System.out.println("Table2 Created.");
    String name =
        spans.get(0).text()
            + " "
            + spans.get(2).text()
            + " "
            + spans.get(3).text()
            + " "
            + spans.get(4).text()
            + " "
            + spans.get(5).text();
    LOGGER.info("New Table2. The title roughly starts with: " + name);
    LOGGER.info("I was found in: " + file.getName());
    System.out.println("My name is: " + name);

    this.workLocation = workLocation;
    this.spans = spans;
    this.columns = new ArrayList<ArrayList<Element>>();
    this.name = name;
    // ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
    System.out.println("Now we recreate the table using the positions. This might add more data!");

    Scores score = new Scores(spans);
    this.endOfTable = score.findEndOfTable();
    this.beginOfTable = score.findBeginOfTable();
    this.distanceConstant = score.getDistanceConstant();

    LOGGER.info("Begin of the table at " + beginOfTable);
    LOGGER.info("End of the table at: " + endOfTable);

    System.out.println("Begin of the table at " + beginOfTable);
    System.out.println("End of the table at: " + endOfTable);
    this.tableMap = createTableMap(endOfTable);
    checkMapForX2Columns();

    setColumnsContent();

    // TODO: Refine to column one more time so it also give the full header.

    String content = "<results>\n"; // used for the XML output
    String data = "";

    for (ArrayList<Element> column : columns) {
      try {
        Column col = new Column(column);
        data = data + col.getColumnContentInXML();
        this.distanceThreshold = col.getHeightThreshold();
      } catch (NullPointerException e) {
        continue;
      }
    }
    content = content + data;
    content = content + "</results>\n";
    System.out.println("Writing to file: ");
    write(content, workLocation + "/results/" + name + ".xml", file);
  }
Esempio n. 15
0
 private static void parseStatHeader(Document doc, Statistic stat) {
   Elements mainStatsTds = doc.select("div#div_ppy").select("tr").select("td");
   String picks = mainStatsTds.get(0).text().replace("picks", "").trim();
   String profit = mainStatsTds.get(1).text().replace("profit", "").trim();
   String yield = mainStatsTds.get(2).text().replace("yield", "").trim();
   stat.setPicks(NumberParser.parseInt(picks));
   stat.setProfit(NumberParser.parseInt(profit));
   stat.setYield(NumberParser.parseInt(yield));
 }
Esempio n. 16
0
  private boolean isFirstModel(Elements headers) {
    // TODO Auto-generated method stub
    String poids = headers.get(2).text();
    String cordes = headers.get(3).text();
    String oeilleres = headers.get(8).text();

    if (poids.equals("Poids") && cordes.equals("Corde") && oeilleres.equals("Oeill.")) return true;
    else return false;
  }
Esempio n. 17
0
  public static String evSelTxt(Element entry, String sel) {

    Elements els = entry.select(sel);
    if (els.size() == 1 && els.get(0) != null) {
      return els.get(0).text();
    }
    log.error("no match per: " + sel);
    return null;
  }
Esempio n. 18
0
 public void parseWebLink() throws IOException {
   Document doc = Jsoup.connect(url).get();
   Elements info = doc.select("div[id*=MediaStoryList");
   Elements links = info.select("a[href]");
   boolean writeOrNot = true;
   try {
     /* define timeToken to compare either the target urls in the file */
     SimpleDateFormat sdf = new SimpleDateFormat("yyMMddHH");
     Date rightNow = new Date();
     String timeToken = sdf.format(rightNow);
     /* read the target#.txt where # is node id file to decide write or not */
     File file = new File("News/target" + node_id + ".txt");
     if (file.exists()) {
       FileInputStream fstream = new FileInputStream("News/target" + node_id + ".txt");
       DataInputStream in = new DataInputStream(fstream);
       BufferedReader br = new BufferedReader(new InputStreamReader(in));
       String strLine;
       int isSame = 1;
       while ((strLine = br.readLine()) != null) {
         isSame = strLine.compareTo(timeToken + "count = " + count);
         if (isSame == 0) {
           writeOrNot = false;
           System.out.println(
               "The set of urls have already written in the file:target" + node_id + ".txt");
         }
       }
       // Close the input stream
       in.close();
     }
     /* end the reading file */
     /* decide write or not */
     if (writeOrNot) {
       /* write to file named target#.txt where # is node id */
       FileWriter outputToTxt = new FileWriter("News/target" + node_id + ".txt", true);
       BufferedWriter writeToFile = new BufferedWriter(outputToTxt);
       writeToFile.write(timeToken + "count = " + count);
       writeToFile.newLine();
       int urlIsSame = 1;
       for (int i = 0; i < links.size(); i++) {
         String levelTwoUrl = links.get(i).attr("href");
         // String compareIsSame = links.get(i+1).attr("href");
         // System.out.println(line + "\n");
         if (i != 0) {
           urlIsSame = levelTwoUrl.compareTo(links.get(i - 1).attr("href"));
         }
         if (urlIsSame != 0) {
           writeToFile.write(levelTwoUrl);
           writeToFile.newLine();
         }
       }
       writeToFile.close();
       System.out.println("The file : target" + node_id + ".txt is written!");
     }
   } catch (IOException e) {
     System.out.println("The IO Error msg is:" + e.getMessage());
   }
 }
Esempio n. 19
0
  private void saveSmsLog(
      SimpleObject context,
      final int page,
      final int t,
      final Date d,
      final String dstr,
      final int isHistory) {
    String text = ContextUtil.getContent(context);
    Document doc = ContextUtil.getDocumentOfContent(context);
    System.out.println(doc.toString());
    if (text.indexOf("没有查找到相关数据") >= 0) {
      return;
    }
    String tableSort = InfoUtil.getInstance().getInfo("dx/sh", "tableSort");
    String tbody = InfoUtil.getInstance().getInfo("dx/sh", "tbody");
    String tr = InfoUtil.getInstance().getInfo("dx/sh", "tr");
    String td = InfoUtil.getInstance().getInfo("dx/sh", "td");
    Elements elements = doc.select(tableSort);
    if (elements != null && elements.size() > 0) {
      Elements elements2 = elements.first().select(tbody).first().select(tr);
      for (int j = 0; j < elements2.size(); j++) {
        try {
          Elements tds = elements2.get(j).select(td);
          if (tds.size() == 5) {
            String RecevierPhone = tds.get(2).text().trim(); // 对方号码
            String SentTime = tds.get(1).text().trim(); // 发送时间
            String BusinessType = tds.get(3).text().trim(); // 费用类型
            String AllPay = tds.get(4).text().trim(); // 费用

            Date sentTime = null;
            try {
              sentTime = DateUtils.StringToDate(SentTime, "yyyy-MM-dd HH:mm:ss");
            } catch (Exception e) {
              e.printStackTrace();
            }
            TelcomMessage obj = new TelcomMessage();
            obj.setPhone(phoneNo);
            UUID uuid = UUID.randomUUID();
            obj.setId(uuid.toString());
            obj.setBusinessType(BusinessType); // 业务类型:点对点
            obj.setRecevierPhone(RecevierPhone); // 对方号码
            obj.setSentTime(sentTime); // 发送时间
            obj.setCreateTs(new Date());
            obj.setAllPay(Double.parseDouble(AllPay)); // 总费用
            messageList.add(obj);
          }

        } catch (Exception e) {
          logger.error("saveSmsLog", e);
        }
      }
      if (text.contains("下一页")) {
        requestSmsLogService(page + 1, 1, d, dstr, isHistory);
      }
    }
  }
Esempio n. 20
0
  public static String evSelAttrTxt(Element entry, String sel, String attr) {

    Elements els = entry.select(sel);
    if (els.size() == 1 && els.get(0).attr(attr) != null) {
      return els.get(0).attr(attr);
    }

    log.error("unable to find attribute " + attr + " in " + entry);
    return null;
  }
 private Map<Element, Elements> mapSectionTypeToEntryRows(
     Elements sectionTypes, Elements sectionEntryTables) {
   Map<Element, Elements> sectionTypeToEntryRows = new HashMap<>();
   for (int i = 0; i < sectionTypes.size(); i++) {
     Elements entryRows = sectionEntryTables.get(i).select("tr");
     Elements entryRowsWithoutHeaders = deleteHeaderRow(entryRows);
     sectionTypeToEntryRows.put(sectionTypes.get(i), entryRowsWithoutHeaders);
   }
   return sectionTypeToEntryRows;
 }
Esempio n. 22
0
 private TarifaTelevisao getTarifaTelevisao(Element element) {
   Elements cells = element.getElementsByTag("td");
   return new TarifaTelevisao(
       cells.get(1).text(),
       cells.get(2).text(),
       cells.get(6).text(),
       cells.get(3).text(),
       cells.get(4).text(),
       cells.get(5).text());
 }
Esempio n. 23
0
  @Test
  public void elementIsNotASiblingOfItself() {
    Document doc = Jsoup.parse("<div><p>One<p>Two<p>Three</div>");
    Element p2 = doc.select("p").get(1);

    assertEquals("Two", p2.text());
    Elements els = p2.siblingElements();
    assertEquals(2, els.size());
    assertEquals("<p>One</p>", els.get(0).outerHtml());
    assertEquals("<p>Three</p>", els.get(1).outerHtml());
  }
Esempio n. 24
0
  private void parseFeedItem(String resource) {
    try {
      Document doc = Jsoup.parse(resource);
      Element masthead = doc.select("div.tie-wrapper").first();
      Elements feedBoxs = masthead.select("div.tie-box");

      for (int i = 0; i < feedBoxs.size(); i++) {

        FeedItem feedItem = new FeedItem();

        Element feedPost = feedBoxs.get(i);

        Element titleElement = feedPost.select("div.tie-header h2.tie-title a").first();

        Element nameElement =
            feedPost.select("div.tie-content div.tie-user div.user-info p span.user-name").first();
        Element sourceElement =
            feedPost.select("div.tie-content div.tie-user div.user-info p span.user-form").first();
        Element timestampElement =
            feedPost.select("div.tie-content div.tie-user div.user-info p.tie-date").first();
        Elements imageElement = feedPost.select("div.tie-content img.st-photo");
        Elements contentElements = feedPost.select("div.tie-content p:not(.tie-date):gt(0)");

        String title = titleElement.text();
        String name = nameElement.text();
        String source = sourceElement.text();
        String timestamp = timestampElement.text();

        String content = "";
        for (int j = 0; j < contentElements.size(); j++) {
          content = content + contentElements.get(j).text() + "\n";
        }

        String image;
        if (imageElement.attr("src") != "") {
          image = url + imageElement.attr("src");
        } else {
          image = null;
        }

        feedItem.setTitle(title);
        feedItem.setName(name);
        feedItem.setPostTime(timestamp);
        feedItem.setSource(source);
        feedItem.setImage(image);
        feedItem.setContent(content);

        mFeedItems.add(feedItem);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    mFeedItemAdapter.notifyDataSetChanged();
  }
Esempio n. 25
0
 private TarifaInternet getTarifaInternet(Element element) {
   Elements cells = element.getElementsByTag("td");
   return new TarifaInternet(
       cells.get(1).text(),
       cells.get(2).text(),
       cells.get(3).text(),
       cells.get(4).text(),
       cells.get(5).text(),
       cells.get(6).text(),
       cells.get(7).text());
 }
  @Test
  public void shouldRenderDocStringInTagReport() throws Exception {
    File rd =
        new File(
            ReportBuilderTest.class
                .getClassLoader()
                .getResource("net/masterthought/cucumber")
                .toURI());
    List<String> jsonReports = new ArrayList<String>();
    jsonReports.add(
        new File(
                ReportBuilderTest.class
                    .getClassLoader()
                    .getResource("net/masterthought/cucumber/docstring.json")
                    .toURI())
            .getAbsolutePath());
    ReportBuilder reportBuilder =
        new ReportBuilder(
            jsonReports,
            rd,
            "/jenkins/",
            "1",
            "cucumber-reporting",
            false,
            false,
            false,
            false,
            true,
            true,
            false,
            "",
            false,
            false);
    reportBuilder.generateReports();

    File input = new File(rd, "tag-1.html");
    Document doc = Jsoup.parse(input, "UTF-8", "");
    assertThat(fromClass("doc-string", doc).get(0).text(), is("X _ X O X O _ O X"));
    Elements tableCells =
        doc.getElementsByClass("stats-table")
            .get(0)
            .getElementsByTag("tr")
            .get(2)
            .getElementsByTag("td");
    assertEquals("@tag:1", tableCells.get(0).text());
    assertEquals("1", tableCells.get(1).text());
    assertEquals("1", tableCells.get(2).text());
    assertEquals("0", tableCells.get(3).text());
    assertEquals("2", tableCells.get(4).text());
    assertEquals("2", tableCells.get(5).text());
    assertEquals("0", tableCells.get(6).text());
    assertEquals("0", tableCells.get(7).text());
    assertEquals("0", tableCells.get(8).text());
    assertEquals("0", tableCells.get(9).text());
    assertEquals("0", tableCells.get(10).text());
    assertEquals("106ms", tableCells.get(11).text());
    assertEquals("passed", tableCells.get(12).text());
  }
Esempio n. 27
0
  @Test
  public void testGetParents() {
    Document doc = Jsoup.parse("<div><p>Hello <span>there</span></div>");
    Element span = doc.select("span").first();
    Elements parents = span.parents();

    assertEquals(4, parents.size());
    assertEquals("p", parents.get(0).tagName());
    assertEquals("div", parents.get(1).tagName());
    assertEquals("body", parents.get(2).tagName());
    assertEquals("html", parents.get(3).tagName());
  }
Esempio n. 28
0
 private boolean isSubscriptTable(final Element table) {
   final Elements trs = table.getElementsByTag("tr");
   if (trs != null && !trs.isEmpty()) {
     final Element head = trs.get(0);
     final Elements tds = head.getElementsByTag("th");
     if (tds != null && !tds.isEmpty()) {
       final String text = tds.get(0).text();
       return text != null && text.contains("Teilnehmer");
     }
   }
   return false;
 }
Esempio n. 29
0
  public static void mbbPage() throws IOException {

    String mbaobaoURL = "http://item.mbaobao.com/pshow-1108000903.html?l=hc-r";
    Document mbbDoc = Jsoup.parse(new URL(mbaobaoURL), 20000);

    Elements elements = mbbDoc.select("li.goods-number").select("div");

    System.out.println("麦包包商品编号:[" + elements.get(0).childNode(0) + "]");

    elements = mbbDoc.select("li.goods-mb-price").select("span.g-p-n");

    System.out.println("麦包包当前价格:[" + elements.get(0).childNode(1) + "]");
  }
 private CalendarSupplementalEntry createSupplementalEntry(
     CalendarSupplemental supplemental,
     CalendarSectionType calendarSectionType,
     Element entryTable) {
   Elements columns = entryTable.select("td");
   int billCalNo = Integer.valueOf(columns.get(0).text());
   String printNo = "S" + columns.get(2).text();
   BillId billId = new BillId(printNo, supplemental.getSession());
   // TODO find examples of these
   //        BillId subBillId;
   //        boolean high; // high status is not available in alert emails.
   return new CalendarSupplementalEntry(billCalNo, calendarSectionType, billId, null, null);
 }