Пример #1
0
        static string GetCodeData(string code, string beginTime, string curTime)
        {
            try
            {
                string   url      = string.Format(GetHttpData.urlFormat, "", code, beginTime, curTime);
                string   contents = GetHttpData.GetUrltoHtml(url, "GB18030");
                string[] lines    = contents.Split('\n');

                // 记录数过滤。。。
                if (lines.Length <= 3)
                {
                    return(null);
                }

                CStockContents sc = new CStockContents();

                for (int j = lines.Length - 1; j > 0; --j)
                {
                    // 过滤停。。。
                    if (lines[j].Contains("None,") || lines[j] == "")
                    {
                        continue;
                    }

                    CLineContents lc = new CLineContents(lines[j]);
                    sc.Push(lc);

                    if (j == 1)
                    {
                        CLineContents lcTmp = GetRealtimeData(code);
                        if (lcTmp != null)
                        {
                            sc.Push(lcTmp);
                        }
                    }
                }
                string res = sc.GetResult();
                if (res != null || res != "")
                {
                    return(res);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString() + "\n" + code);
            }
            return(null);
        }
Пример #2
0
        static string GetCodeData(string code, string beginTime, string curTime)
        {
            try
            {
                string url = string.Format(GetHttpData.urlFormat, "", code, beginTime, curTime);
                string contents = GetHttpData.GetUrltoHtml(url, "GB18030");
                string[] lines = contents.Split('\n');

                // 记录数过滤。。。
                if (lines.Length <= 3) return null;

                CStockContents sc = new CStockContents();

                for (int j = lines.Length - 1; j > 0; --j)
                {
                    // 过滤停。。。
                    if (lines[j].Contains("None,") || lines[j] == "")
                        continue;

                    CLineContents lc = new CLineContents(lines[j]);
                    sc.Push(lc);

                    if (j == 1)
                    {
                        CLineContents lcTmp = GetRealtimeData(code);
                        if(lcTmp != null)
                            sc.Push(lcTmp);
                    }
                }
                string res = sc.GetResult();
                if (res != null || res != "")
                    return (res);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString() + "\n" + code);
            }
            return null;
        }