Esempio n. 1
0
        /// <summary>
        /// SINA 融资融券
        /// </summary>
        /// <returns></returns>
        public string GetRZRQ(string stockCode)
        {
            var symbol         = Convertor.AddStockCodePrefix(stockCode);
            var startDate      = string.Format("{0}-01-01", DateTime.Now.Year);
            var endDate        = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
            var url            = string.Format("http://vip.stock.finance.sina.com.cn/q/go.php/vInvestConsult/kind/rzrq/index.phtml?symbol={0}&bdate={1}&edate={2}", symbol, startDate, endDate);
            var httpDownloader = new HTTP();
            var headers        = new Dictionary <HttpRequestHeader, string>();

            headers.Add(HttpRequestHeader.Accept, "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
            headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
            headers.Add(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7");
            headers.Add(HttpRequestHeader.Host, "vip.stock.finance.sina.com.cn");
            headers.Add(HttpRequestHeader.UserAgent, CONST.UserAgent);

            var strData = httpDownloader.GetGzip2(url, Encoding.GetEncoding("GBK"), headers);

            return(strData);
        }
Esempio n. 2
0
        /// <summary>
        /// 历史成交明细
        /// http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol=sh600036&date=2017-10-13
        /// </summary>
        /// <param name="stockcode">类似于 sz300668</param>
        /// <param name="date"></param>
        /// <param name="pageNumber"></param>
        /// <returns></returns>
        public string GetLSCJMX(string stockcode, string date, int pageNumber)
        {
            string url            = string.Format("http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol={0}&date={1}&page={2}", Convertor.AddStockCodePrefix(stockcode), date, pageNumber);
            var    httpdownloader = new HTTP();
            var    headers        = new Dictionary <HttpRequestHeader, string>();

            headers.Add(HttpRequestHeader.Accept, "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
            headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
            headers.Add(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7");
            headers.Add(HttpRequestHeader.Host, "vip.stock.finance.sina.com.cn");
            headers.Add(HttpRequestHeader.Referer, string.Format("http://vip.stock.finance.sina.com.cn/quotes_service/view/vMS_tradehistory.php?symbol={0}&date={1}", stockcode, date));
            headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36");
            headers.Add(HttpRequestHeader.Cookie, "vjuids=-3d20ba9f8.150715b95a8.0.9e4d081a; SGUID=1445010838969_24869349; U_TRS1=00000077.eff21405.56211d98.e270c652; SCF=AiNSdX-kSf4x3r5s3OPpIKeILKce6Ob9lRa-jJt11Vh5r8kMpPU24v_1hNWF-ZDmw1aBetJmtrTPFQDDGaqUuMU.; SINAGLOBAL=123.138.24.104_1468410916.956202; sso_info=v02m6alo5qztKWRk5iljpSMpZCToKWRk5SlkJSQpY6TgKWRk5iljpSQpY6ElLGOk6SziaeVqZmDtLKNs4C2jJOct4yTlLA=; visited_uss=gb_wb; UOR=,,; SR_SEL=1_511; lxlrtst=1509781793_o; close_left_xraytg=1; ");

            var strData = httpdownloader.GetGzip2(url, Encoding.GetEncoding("GBK"), headers);

            return(strData);
        }
Esempio n. 3
0
        /// <summary>
        /// 历史成交明细 页数
        /// http://market.finance.sina.com.cn/transHis.php?date=2017-10-13&symbol=sh600036
        /// </summary>
        public int GetLSCJMXCount(string stockcode, string date)
        {
            string url            = string.Format("http://market.finance.sina.com.cn/transHis.php?date={0}&symbol={1}", date, Convertor.AddStockCodePrefix(stockcode));
            var    httpdownloader = new HTTP();
            var    headers        = new Dictionary <HttpRequestHeader, string>();

            headers.Add(HttpRequestHeader.Accept, "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8");
            headers.Add(HttpRequestHeader.AcceptEncoding, "gzip, deflate");
            headers.Add(HttpRequestHeader.AcceptLanguage, "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7");
            headers.Add(HttpRequestHeader.Host, "market.finance.sina.com.cn");
            headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36");
            headers.Add(HttpRequestHeader.Cookie, "U_TRS1=000000bc.81346475.5a10967a.97e5dd54; U_TRS2=000000bc.813e6475.5a10967a.ecb434e5; FINANCE2=56e2a29d3a8fe026d3c022d0667dda04");

            var strData = httpdownloader.GetGzip2(url, Encoding.GetEncoding("GBK"), headers);

            if (!strData.Contains("输入的代码有误或没有交易数据"))
            {
                var startIndex = strData.IndexOf("var detailPages=") + "var detailPages=".Length;
                var endIndex   = strData.IndexOf("var detailDate =");
                var subString  = strData.Substring(startIndex, endIndex - startIndex);
                var array      = subString.Replace(";", string.Empty).Replace("[[", string.Empty).Replace("]]", string.Empty).Replace("\r\n", string.Empty).Split(new string[] { "],[" }, StringSplitOptions.RemoveEmptyEntries);
                return(array.Length);
            }
            return(0);
        }
Esempio n. 4
0
        public void DownloadExcel(DateTime date, string stockCode, string stockName)
        {
            var httpDownloader = new HTTP();
            var url            = string.Format("http://market.finance.sina.com.cn/downxls.php?date={0}&symbol={1}", string.Format("{0:yyyy-MM-dd}", date), Convertor.AddStockCodePrefix(stockCode));
            var filePath       = string.Format(@"F:\Excel\{0}{1}{2:yyyyMMdd}.xls", stockCode, stockName, date);

            filePath = filePath.Replace("*", "[星]");
            if (!File.Exists(filePath))
            {
                var data = httpDownloader.GetFile(url);
                File.WriteAllBytes(filePath, data);
                ThreadManager.Pause(seconds: 3);
            }
        }