Beispiel #1
0
        public static InfoData BuildBasicInfo(InfoData id)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();

            WebClient client = new WebClient();

            byte[] page = BuildData(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("-") || value1.Equals("empty"))
            {
                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;
        }
Beispiel #2
0
 public static void DownloadSingle(InfoData id)
 {
     DownloadSingle(id.sid);
 }
Beispiel #3
0
        public static InfoData BuildInfo(string sid)
        {
            WebClient client = new WebClient();
            //byte[] page = client.DownloadData(string.Format("http://hq.sinajs.cn/list={0}", sid));
            byte[] page = BuildData(string.Format("http://hq.sinajs.cn/list={0}", sid));
            string content = System.Text.Encoding.GetEncoding("GBK").GetString(page);
            InfoData id = null;
            if (content.Length > 40)
            {
                string name = content.Substring(content.IndexOf("\"") + 1, content.IndexOf(",") - content.IndexOf("\"")).Trim();

                id = new InfoData();
                id.sid = sid;
                id.name = name.EndsWith(",") ? name.Substring(0, name.Length - 1) : name;
                id = BuildBasicInfo(id);
                id = BuildShare(id);
                Console.WriteLine("build complete: " + sid);
            }

            return id;
        }
Beispiel #4
0
        public static InfoData BuildShare(InfoData id)
        {
            Dictionary<string, string> dic = new Dictionary<string, string>();

            // 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 = BuildData(string.Format("http://stockpage.10jqka.com.cn/{0}/holder/", BizCommon.ProcessStockId(id.sid)));
                //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;
            //}
            id.valid = 1;
            return id;
        }