Exemplo 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));
 }
Exemplo n.º 2
0
 public String extract(StockInfo stock, Date date) throws Exception {
   String trans;
   if (year == date.getYear() && quarter == dateToQuarter(date)) {
     trans = map.get(date.toString());
   } else {
     map = new HashMap<String, String>(70);
     if (extractRun(stock, date)) {
       year = date.getYear();
       quarter = dateToQuarter(date);
       trans = map.get(date.toString());
     } else {
       year = Utils.valType.NL;
       quarter = Utils.valType.NL;
       trans = null;
     }
   }
   return trans;
 }
Exemplo n.º 3
0
 private boolean extractRun(StockInfo stock, Date date) 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", String.valueOf(date.getYear()))
           .setParameter("jidu", String.valueOf(dateToQuarter(date)))
           .build();
   DownloadHelper download = new DownloadHelper(uri);
   InputStream is = download.getInputStream();
   boolean ret = jsoupImpl(is);
   is.close();
   download.close();
   return ret;
 }
Exemplo n.º 4
0
 private int dateToQuarter(Date date) {
   return (date.getMonth() - 1) / 3 + 1;
 }