private void GetMyAssets(bool printMessage) { if (printMessage) SetMessageLn("读取我的资产信息..."); this._myAssetsList.Clear(); int page = 0; int maxrequest = 0; do { //防止死循环 if (maxrequest > 20) return; maxrequest++; int num; HH.DelayedTime = Constants.DELAY_1SECONDS; string content = HH.Get("http://www.kaixin001.com/!rich/myitem.php&start=" + page); content = JsonHelper.GetMid(content, "<div class=\"list_zc\">", "<div class=\"tac mt30\">"); if (content != null) { if (content == "\r\n\r\n\t\t\t<div class=\"c\"></div>\r\n\t\t</div>\r\n\t\t") return; if (printMessage) SetMessageLn("第" + (page / 20 + 1).ToString() + "页"); for (string info = JsonHelper.GetMid(content, "<ul>", "</ul>", out num); info != null; info = JsonHelper.GetMid(content, "<ul>", "</ul>", out num)) { content = content.Substring(num); string detail = JsonHelper.GetMid(info, "<a href=\"javascript:sell(", ");\""); string[] details = detail.Split(','); string assetnum = JsonHelper.GetMid(info, "</b> ", " <img src="); //<li class="tac mt5" ><b>石油天然气公司</b> 100家 <img src="http://img.kaixin001.com.cn/i3/dh/icon_u.gif" /></li> if (assetnum==null) assetnum = JsonHelper.GetMid(info, "</b> ", " </li>"); //<li class="tac mt5" style="margin-top:14px"><b>诺亚方舟船票</b> 2张 </li> if (details != null && details.Length == 3) { MyAssetInfo myasset = new MyAssetInfo(); myasset.IId = DataConvert.GetInt32(details[0]); myasset.BuyPrice = DataConvert.GetDouble(details[1]); myasset.CurrentPrice = DataConvert.GetDouble(JsonHelper.GetMid(details[2], "'", "'")); myasset.AssetNum = DataConvert.GetInt32(assetnum.Substring(0, assetnum.Length - 1)); this._myAssetsList.Add(myasset); if (printMessage) SetMessageLn(myasset.ToString()); } } page += 20; } else { return; } } while (true); }
private void GetMyAssets(bool printMessage) { if (printMessage) { SetMessageLn("读取我的资产信息..."); } this._myAssetsList.Clear(); int page = 0; int maxrequest = 0; do { //防止死循环 if (maxrequest > 20) { return; } maxrequest++; int num; HH.DelayedTime = Constants.DELAY_1SECONDS; string content = HH.Get("http://www.kaixin001.com/!rich/myitem.php&start=" + page); content = JsonHelper.GetMid(content, "<div class=\"list_zc\">", "<div class=\"tac mt30\">"); if (content != null) { if (content == "\r\n\r\n\t\t\t<div class=\"c\"></div>\r\n\t\t</div>\r\n\t\t") { return; } if (printMessage) { SetMessageLn("第" + (page / 20 + 1).ToString() + "页"); } for (string info = JsonHelper.GetMid(content, "<ul>", "</ul>", out num); info != null; info = JsonHelper.GetMid(content, "<ul>", "</ul>", out num)) { content = content.Substring(num); string detail = JsonHelper.GetMid(info, "<a href=\"javascript:sell(", ");\""); string[] details = detail.Split(','); string assetnum = JsonHelper.GetMid(info, "</b> ", " <img src="); //<li class="tac mt5" ><b>石油天然气公司</b> 100家 <img src="http://img.kaixin001.com.cn/i3/dh/icon_u.gif" /></li> if (assetnum == null) { assetnum = JsonHelper.GetMid(info, "</b> ", " </li>"); //<li class="tac mt5" style="margin-top:14px"><b>诺亚方舟船票</b> 2张 </li> } if (details != null && details.Length == 3) { MyAssetInfo myasset = new MyAssetInfo(); myasset.IId = DataConvert.GetInt32(details[0]); myasset.BuyPrice = DataConvert.GetDouble(details[1]); myasset.CurrentPrice = DataConvert.GetDouble(JsonHelper.GetMid(details[2], "'", "'")); myasset.AssetNum = DataConvert.GetInt32(assetnum.Substring(0, assetnum.Length - 1)); this._myAssetsList.Add(myasset); if (printMessage) { SetMessageLn(myasset.ToString()); } } } page += 20; } else { return; } }while (true); }