Exemplo n.º 1
0
        public static InfoData BuildShare(InfoData id)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();
            WebClient client = new WebClient();

            // Stream data = client.OpenRead(string.Format("http://stockpage.10jqka.com.cn/{0}/company/", stock));
            // StreamReader reader = new StreamReader(data);
            //string s = reader.ReadToEnd();
            byte[] page = client.DownloadData(string.Format("http://stockpage.10jqka.com.cn/{0}/holder/", BizCommon.ProcessStockId(id.sid)));

            string content = System.Text.Encoding.UTF8.GetString(page);

            //string content = "成交额:1.62 亿元";

            string[] match = { @"前十大流通股东累计持有:<em>(.*)</em>万股", @"累计占流通股比:<em>(.*)%</em>", @"前十大股东累计持有:<em>(.*)</em>万股", @"累计占总股本比:<em>(.*)%</em>" };

            string[] values = new string[match.Length];
            for (int i = 0; i < match.Length; i++)
            {
                Regex           re      = new Regex(match[i]);
                MatchCollection matches = re.Matches(content);
                values[i] = matches.Count > 0 ? matches[0].Groups[1].Value : "empty";
            }
            for (int j = 0; j < values.Length; j++)
            {
                values[j] = values[j] == "empty" ? "1" : values[j];
            }
            decimal floatshare = (Decimal.Parse(values[0]) / Decimal.Parse(values[1] == "empty" ? "1" : values[1]) * 100);

            id.totalshare = (Double)(Decimal.Parse(values[2]) / Decimal.Parse(values[3]) * 100);
            id.floatshare = (Double)floatshare;
            id.top10total = Decimal.Parse(values[1]);
            id.top10float = Decimal.Parse(values[3]);
            id.weight     = GetWeight(floatshare);
            int w = (int)Math.Round(id.weight * 10);

            id.list = string.Format("{0},{1},{2}", 50 * w, 100 * w, 200 * w);
            if (id.totalshare == 100f || id.floatshare == 100f)
            {
                id.valid = 0;
            }
            else
            {
                id.valid = 1;
            }
            return(id);
        }
Exemplo n.º 2
0
        public static InfoData BuildBasicInfo(InfoData id)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();

            WebClient client = new WebClient();

            byte[] page = client.DownloadData(string.Format("http://stockpage.10jqka.com.cn/{0}/company/", BizCommon.ProcessStockId(id.sid)));

            string content = System.Text.Encoding.UTF8.GetString(page);

            //string content = "成交额:1.62 亿元";

            string[] match = { @"所属地域:", @"所属行业:" };


            Regex           re      = new Regex(match[0] + "</strong><span>(.*)</span>");
            MatchCollection matches = re.Matches(content);
            string          value   = matches.Count > 0 ? matches[0].Groups[1].Value : "empty";

            id.location = value;

            Regex           re1      = new Regex(match[1] + "</strong><span>(.*)</span>");
            MatchCollection matches1 = re1.Matches(content);
            string          value1   = matches1.Count > 0 ? matches1[0].Groups[1].Value : "empty";

            if (value1.Equals("-"))
            {
                string[] list = value1.Split('—');

                id.firstlevel  = "";
                id.secondlevel = "";
            }
            else
            {
                string[] list = value1.Split('—');

                id.firstlevel  = string.IsNullOrEmpty(list[0]) ? "" : list[0].Trim();
                id.secondlevel = string.IsNullOrEmpty(list[1]) ? "" : list[1].Trim();
            }
            return(id);
        }
Exemplo n.º 3
0
        public static InfoExtData1 QueryInfoExtFromTonghuashun(string sid)
        {
            InfoExtData1 ifd = new InfoExtData1();

            ifd.sid = sid;
            //Console.WriteLine("start");
            try
            {
                string       url      = "http://stockpage.10jqka.com.cn/" + BizCommon.ProcessStockId(sid);
                WebClient    client   = new WebClient();
                byte[]       gg       = client.DownloadData(url);
                string       haha     = System.Text.Encoding.UTF8.GetString(gg);
                TextReader   stream   = new StringReader(haha);
                HtmlDocument document = new HtmlDocument();
                document.Load(stream);

                HtmlNode           rootNode = document.DocumentNode;
                HtmlNodeCollection c        = rootNode.SelectNodes("//dl[@class='company_details']");

                //处理html
                string innerString = c[0].InnerText;
                innerString = innerString.Replace(System.Environment.NewLine, "");
                innerString = innerString.Replace("\t", " ");
                innerString = System.Text.RegularExpressions.Regex.Replace(innerString, @"\s{1,}", " ", RegexOptions.IgnoreCase);
                innerString = innerString.Replace(": ", ":");

                string[] array = innerString.Split(' ');
                foreach (string item in array)
                {
                    if (item.Trim().Length > -1 && item.IndexOf(":") > -1)
                    {
                        string[] bb = item.Split(':');
                        switch (bb[0].Trim())
                        {
                        case "总股本":     //亿股
                            ifd.zongguben = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "流通股":    //亿股
                            ifd.liutonggu = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "营业收入增长率":
                            ifd.yingyeshouruzengzhanglv = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "营业收入":     //亿元
                            ifd.yingyeshouru = decimal.Parse(bb[1].Substring(0, bb[1].Length - 2));
                            break;

                        case "净利润":    //亿元
                            ifd.jinglirun = decimal.Parse(bb[1].Substring(0, bb[1].Length - 2));
                            break;

                        case "净利润增长率":
                            ifd.jinglirunzengzhanglv = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "每股收益":    //元
                            ifd.meigujingzichan = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "每股净资产":    //元
                            ifd.meigujingzichan = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "净资产收益率":
                            ifd.jingzichanshouyilv = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "每股现金流":    //元
                            ifd.meiguxianjinliu = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "每股公积金":    //元
                            ifd.meigugongjijin = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;

                        case "每股未分配利润":    //元
                            ifd.meiguweifenpeilirun = decimal.Parse(bb[1].Substring(0, bb[1].Length - 1));
                            break;
                        }
                    }
                }
            }
            catch
            {
                StockLog.Log.Error(sid + " infoext import fail");
            }

            return(ifd);
        }