//---------------------------------------------------------------------------- private DownLoadData Deserialize(string json) { DownLoadData data = JsonReader.Deserialize <DownLoadData>(json); Debug.Log("开奖日期: " + data.result[0].date); Debug.Log("期数: " + data.result[0].code); Debug.Log("红球: " + data.result[0].red); Debug.Log("篮球: " + data.result[0].blue); Debug.Log("本期销售额:" + data.result[0].sales); Debug.Log("奖池滚存: " + data.result[0].poolmoney); Debug.Log("一等奖注数: " + data.result[0].prizegrades[0].typenum); Debug.Log("一等奖中奖金额: " + data.result[0].prizegrades[0].typemoney); Debug.Log("一等奖中奖地区: " + data.result[0].content); Debug.Log("二等奖中奖注数:" + data.result[0].prizegrades[1].typenum); Debug.Log("二等奖中奖金额:" + data.result[0].prizegrades[1].typemoney); return(data); }
//---------------------------------------------------------------------------- private void OnOneHundredClick() { System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); sw.Start(); http = new HttpHelper(); item = new HttpItem { URL = DownLoadManager.OneHundredDoAddress, //URL 必需项 Method = DownLoadManager.MethodType, //URL 可选项 默认为Get Timeout = DownLoadManager.TimeOunt, //连接超时时间 可选项默认为100000 ReadWriteTimeout = DownLoadManager.ReadWriteTimeout, //写入Post数据超时时间 可选项默认为30000 IsToLower = DownLoadManager.IsToLower, //得到的HTML代码是否转成小写 可选项默认转小写 Cookie = DownLoadManager.Cookie, //字符串Cookie 可选项 UserAgent = DownLoadManager.UserAgent, //用户的浏览器类型,版本,操作系统 可选项有默认值 Accept = DownLoadManager.Accept, //可选项 有默认值 ContentType = DownLoadManager.ContentType, //返回类型 可选项有默认值 Referer = DownLoadManager.SourceAddress, //来源URL 可选项 Allowautoredirect = DownLoadManager.Allowautoredirect, //是否根据301跳转 可选项 AutoRedirectCookie = DownLoadManager.AutoRedirectCookie, //是否自动处理Cookie 可选项 Postdata = DownLoadManager.Postdata, //Post数据 可选项GET时不需要写 ResultType = ResultType.String, //返回数据类型,是Byte还是String }; var httpResult = http.GetHtml(item); if (httpResult.StatusCode == HttpStatusCode.OK) { html = httpResult.Html; Debug.Log("html: " + html); DownLoadData downdata = Deserialize(html); drawData.SerializeAndSaveDownData(downdata); drawData.SerializeAndSaveHistoricalData(); } else { Debug.LogError("result.StatusCode: " + httpResult.StatusCode); } DownLoadRedBallKillData(); DownLoadBuleBallKillData(); sw.Stop(); Debug.LogError(string.Format("下载100数据花费时间为: {0} ms", sw.ElapsedMilliseconds)); }