static void Main(string[] args) { SetConsoleInfo("新版测试"); #region 花顺数据测试 var inst = THS.GetInst(); //inst.GetTodayNewData(); #endregion #region 数据库测试 // var res = mongo.GetCollectionStatistic("ths"); #endregion #region 接口测试 //var res = FanyYiJunAPI.Invoke("你好"); #endregion #region 数据转换测试 //DBConvertor.FromMongoDBToSQLServer("", "", "", "", "", ""); #endregion #region 新浪大单测试 SinaFin sina = new SinaFin(); //sina.ConvertKLine2D("", "", "", "", "", ""); #endregion #region 金融街 var jrj = new JRJ(); //jrj.GetKLine(); #endregion #region SQL Server 测试 //mssql.IsExistUserTable("Test"); #endregion #region Task测试 SystemTask task = new SystemTask(); task.ExecuteTask(TaskItem.CreateAsInterval()); #endregion Console.WriteLine("全部结束"); Console.ReadKey(); }
/// <summary> /// 下载每个股票的页面 UTF8 /// </summary> public void GetPageKLineJRJ() { this.GetALLStockCode(); ///准备所有股票代码 var queueUrl = new Queue <string>(); var httpdownloader = new HTTP(Encoding.UTF8); httpdownloader.EventException += (object sender, EventArgs e) => { var ee = e as EventProcEventArgs; Console.WriteLine("下载失败 {0}", ee.Default); var item = ee.Default as Dictionary <string, object>; item["ContentType"] = "JRJ个股日线页面下载失败异常信息"; item["TaskID"] = THS.CONST.TaskID; var url = item["Url"].ToString(); var type = string.Empty; mongo.Save(THS.CONST.DBName, THS.CONST.Exception, item); #region 类型判断 if (url.Contains("/01/last.js")) { type = "日线数据"; } #endregion Thread.Sleep(60 * 1000); }; if (null != this.stockCodeDict) { foreach (var item in this.stockCodeDict) { queueUrl.Enqueue(item.Key);///Key:StockCode Value:StockName } } var jrj = new JRJ(); while (0 < queueUrl.Count) { var stockCode = queueUrl.Dequeue(); var html = jrj.GetKLine(stockCode); var item = new { StockCode = stockCode, StockName = this.stockCodeDict[stockCode], ContentType = "JRJ日线数据", Url = string.Format("http://flashdata2.jrj.com.cn/history/js/share/{0}/other/dayk_ex.js?random=1510076545082", stockCode), CreatTime = DateTime.Now, Page = html, MD5 = Convertor.Encode_MD5(html), TaskID = THS.CONST.TaskID }; var collectionName = THS.CONST.PageKLine; mongo.Save(THS.CONST.DBName, collectionName, item); Console.WriteLine("已保存 " + stockCode + " " + queueUrl.Count); Thread.Sleep(2000); } }