예제 #1
0
        public void DownloadMarketCapFiles()
        {
            string currentFile = string.Empty;

            try
            {
                String[] categories = File.ReadAllLines(MCapFile);
                if (!Directory.Exists(MCapCacheDir))
                {
                    Directory.CreateDirectory(MCapCacheDir);
                }
                foreach (var category in categories)
                {
                    if (File.Exists(MCapCacheDir + category))
                    {
                        continue;
                    }

                    var request = new HttpRequestManager()
                    {
                        Uri = $"{MCStocks}marketinfo/marketcap/bse/" + category
                    };
                    currentFile = request.Uri;
                    File.WriteAllText(MCapCacheDir + category, request.GetData());
                    Console.WriteLine($"Downloaded file: {currentFile}");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString() + $"\n{currentFile}");
            }
        }
예제 #2
0
        private void DownloadFinancial(string type, string company, int counter)
        {
            var    year1     = (DateTime.Now.Year - 5);
            var    year2     = DateTime.Now.Year;
            string startYear = counter == 0 ? year1.ToString() : year2.ToString();
            string endYear   = counter == 0 ? year2.ToString() : (year1 + 1).ToString();
            string direction = counter == 0 ? "prev" : "next";

            string urlType  = type == Bal ? "balance-sheetVI" : type == Prof ? "profit-lossVI" : "cash?";
            string postType = type == Bal ?  "balance_VI" : type == Prof ? "profit_VI" : "cash?";
            var    request  = new HttpRequestManager()
            {
                // Uri = $"{MCStocks}{financials}{company}&type=balance"
                Uri         = $"{MCStocks}{urlType}/{company}",
                Method      = HttpRequestManager.MethodPost,
                PostContent = $"nav={direction}&type={postType}&sc_did={company}&start_year={startYear}03&end_year={endYear}03&max_year={startYear}03"
            };

            File.WriteAllText($"{CompanyCacheDir}{company}_{type}_{counter}.html", request.GetData());
            Console.WriteLine($"Downloaded financial: {request.Uri}");
            Console.WriteLine($"Body: {request.PostContent}");
        }