public static List <FenXiaoModel> GetProductFromVender(string html) { List <FenXiaoModel> list = new List <FenXiaoModel>(); string content = NetDataManager.GetContent(html, "J_MyItemList", ">", "</table>"); const string find = "<tr class=\"item\">"; int index = content.IndexOf(find); while (index != -1) { int endIndex = content.IndexOf(find, index + find.Length); string tmp; if (endIndex == -1) { tmp = content.Substring(index); } else { tmp = content.Substring(index, endIndex - index); } FenXiaoModel model = CreateProductFromVender(tmp); if (model != null) { list.Add(model); } index = content.IndexOf(find, index + find.Length); } return(list); }
public static string GetNewTitle2(string title) { string newTitle = string.Empty; string url = string.Format("http://s.taobao.com/search?q={0}&app=detail", HttpUtility.UrlEncode(title, Context.HttpEncoding)); string content = NetDataManager.GetString(url); string body = NetDataManager.GetContent(content, "class=\"tb-content\"", "class=\"row grid-view newsrp-gridcontent-el\"", "<div class=\"tb-bottom\">"); string matchString = "\\<div class=\"similar-btns\"\\>\\n*\\s*\\<span class=\"devide-line\"\\>\\<\\/span\\>\\n*\\s*\\<a target=\"_blank\" href=\"(?<url>.*?)\""; Match match = Regex.Match(body, matchString); if (match.Success) { string tongkuanUrl = match.Groups["url"].Value; newTitle = GetTongKuan(url, tongkuanUrl); } if (newTitle != null) { newTitle = newTitle.Replace("包邮", string.Empty); } return(newTitle); }
static void Main() { NetDataManager.UseSpicalEncoding("gb2312"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainFrm()); }
public static List <FenXiaoModel> GetProductOffline() { string url = "http://goods.gongxiao.tmall.com/distributor/item/my_item_list.htm?onSale=0"; string content = NetDataManager.GetString(url); return(SplitTable(content)); }
public static List <FenXiaoModel> SplitTable(string content) { string body = NetDataManager.GetContent(content, "J_FormMyItemList", ">", "</form>"); List <FenXiaoModel> list = new List <FenXiaoModel>(); const string find = "<tr class=\"itemtop\">"; int index = body.IndexOf(find); while (index != -1) { string tmp; int endIndex = body.IndexOf(find, index + 21); if (endIndex == -1) { tmp = body.Substring(index); } else { tmp = body.Substring(index, endIndex - index); } FenXiaoModel model = new FenXiaoModel(); GroupCollection idCol = RegexUtils.Match(tmp, "href=\"(?<url>http://sell.taobao.com/auction/publish/edit.htm\\?item_num_id=(?<id>\\d+?)&auto=false?)\"[^>]+>编辑商品</a></p>"); model.ID = idCol["id"].Value; model.Url = idCol["url"].Value; #region 标题 model.Title = RegexUtils.Match(tmp, "\\<a title=\"产品标题:(?<title>.*?)\"[^>]+\\>")["title"].Value; model.TitleStatus = RegexUtils.Match(tmp, "\\<a title=\"产品标题[^>]+\\> 请修改标题,")[0].Success ? "请修改标题" : ""; #endregion model.PartenerCode = RegexUtils.Match(tmp, "\\<span\\>商家编码: (?<name>.*?)\\</span\\>")["name"].Value; #region 价格 GroupCollection priceCol = RegexUtils.Match(tmp, "<td>(?<price>[\\d.]+?)</td>[\\s\\n]*<td>[\\s\\n]*<p>(?<cost>[\\d.]+?)[\\s\\n]*</p>[\\s\\n]*</td>[\\s\\n]*<td>[\\s\\n]*(?<differ>[\\d.]+?)[\\s\\n]*</td>"); model.Price = priceCol["price"].Value; model.Cost = priceCol["cost"].Value; model.DiffertialCost = priceCol["differ"].Value; #endregion #region Partener GroupCollection partenerCol = RegexUtils.Match(tmp, "\\<a href=\"http://gongxiao.tmall.com/distributor/user/supplier_detail.htm\\?supplierId=(?<id>\\d+?)\"[^>]*>(?<name>.*?)</a>"); model.Partener = partenerCol["name"].Value; model.PartenerID = partenerCol["id"].Value; #endregion model.Inventory = RegexUtils.Match(tmp, "<td id=\"J_store[^\"]+\">[^<]*<p>(?<i>.*?)</p>")["i"].Value; list.Add(model); index = body.IndexOf(find, index + 21); } return(list); }
public void Navigate(string url) { if (!string.IsNullOrEmpty(this.mailUrl)) { url = NetDataManager.GetUrl(this.mailUrl, url); } this.webBrowser.Navigate(url); this.mailUrl = url; }
public void CZprocessNetData(byte[] netData) { // if (netData [0] == 255 && netData [1] == 255 && netData [2] == 255 && (netData [3] == 3 || netData [3] == 2)) // { NetDataManager.addNetData(netData); // Debug.Log("-----------DDDDDDDDDDDDDDDDDDDDDDDDDDDDDD--------------"+netData.Length); // } // else // { // Debug.Log("-----------ffffffffffffffffffffffffffffff--------------"+netData.Length); // } }
// Update is called once per frame void Update() { DateTime t1 = DateTime.Now; NetDataManager.rollreadData(); DateTime t2 = DateTime.Now; TimeSpan ts1 = t2 - t1; // if (ts1.Milliseconds > 5) // { // KDebug.WriteLog("--------------------ReadNetStream too LONG-------------------" + ts1.Milliseconds); // } NetDataManager.update(); }
private static FenXiaoModel CreateProductFromVender(string content) { FenXiaoModel model = new FenXiaoModel(); GroupCollection titleCol = RegexUtils.Match(content, "<p class=\"title\">[\\s\\n]*<a href=\"/product/product_detail.htm\\?productId=(?<id>\\d+)[^>]*>(?<title>.*?)</a>"); model.ID = titleCol["id"].Value; model.Title = titleCol["title"].Value; model.Code = NetDataManager.GetContent(content, "", "商家编码:", "<"); if (!string.IsNullOrEmpty(model.Code)) { model.Code = model.Code.Trim(); } GroupCollection priceCol = RegexUtils.Match(content, "<span class=\"label-like\">利润区间:</span>[\\s\\n]*(?<f>\\<span class=\"ex-knockout-r\"[^>]+>[\\s\\n]*-)?[\\s\\n]*<em>(?<from>.*)</em>[\\s\\n]*~[\\s\\n]*<em>(?<to>.*?)</em>"); model.PriceFrom = priceCol["from"].Value; model.PriceTo = priceCol["to"].Value; model.F = priceCol["f"].Value; model.Inventory = NetDataManager.GetContent(content, "库存:", "\">", "</span>"); if (!string.IsNullOrEmpty(model.Inventory)) { model.Inventory = model.Inventory.Trim(); if (model.Inventory != "有货" && model.Inventory != "部分缺货") { model.Inventory = NetDataManager.GetContent(content, "", "库存:", "<"); if (!string.IsNullOrEmpty(model.Inventory)) { model.Inventory = model.Inventory.Trim(); int count; if (int.TryParse(model.Inventory, out count)) { model.Inventory = count > 0 ? "有货" : "部分缺货"; } else { model.Inventory = "部分缺货"; } } } } model.SellCount = NetDataManager.GetContent(content, "", "<span>成交", "笔</span>"); model.UpdateDate = NetDataManager.GetContent(content, "<span>成交", "铺货:", "</p>"); return(model); }
private void HandleDragCameraEvent(GameObject obj) { /*注释的方案是通过偏移来计算的*/ // Vector3 temp = obj.transform.position - mDragMovePos; // // /*获取制定坐标的网格数据. 这里可以自己添加famecount 来控制帧率*/ // mOriginX += temp.x; // mOriginY += temp.y; // // /*整理数据*/ // mCurNetDataList.Clear(); // List<NetData> netDataList = NetDataManager.GetNetDataList(mOriginX, mOriginY, mCameraMove.mCameraWidth, mCameraMove.mCameraHeight); // if (netDataList != null) // mCurNetDataList.AddRange(netDataList); // // DrawMap(netDataList); // // /*记录上一次的位置*/ // mDragMovePos = obj.transform.position; /*通过估算设置*/ float fTempW = 0f; mOriginX = -GetRealFloat(mCameraMove.mCameraWidth / 2 - mCameraMove.transform.position.x); if (Mathf.Abs(mOriginX) > Mathf.Abs(mCameraMove.mCameraWidth / 2 - mCameraMove.transform.position.x)) { fTempW = 1.0f; } float fTempH = 0f; mOriginY = -GetRealFloat(mCameraMove.mCameraHeight / 2 - mCameraMove.transform.position.y); if (Mathf.Abs(mOriginY) > Mathf.Abs(mCameraMove.mCameraHeight / 2 - mCameraMove.transform.position.y)) { fTempH = 1.0f; } /*整理数据*/ mCurNetDataList.Clear(); List <NetData> netDataList = NetDataManager.GetNetDataList(mOriginX, mOriginY, mCameraMove.mCameraWidth + fTempW, mCameraMove.mCameraHeight + fTempH); if (netDataList != null) { mCurNetDataList.AddRange(netDataList); } DrawMap(netDataList); }
void Start() { /*初始化后台网格数据*/ NetDataManager.InitNetData(); /*检查相机脚本*/ if (mCameraMove == null) { Debug.LogError("您忘记挂在相机脚本了,请在Inspector窗口挂载CameraMove脚本!!!!"); } /*相机回调注册*/ mCameraMove.onDragCameraStart += HandleDragCameraStartEvent; mCameraMove.onDragCamera += HandleDragCameraEvent; mCameraMove.onDragCameraEnd += HandleDragCameraEndEvent; /*获取制定坐标的网格数据*/ float fTempW = 0f; mOriginX = -GetRealFloat(mCameraMove.mCameraWidth / 2); if (Mathf.Abs(mOriginX) > Mathf.Abs(mCameraMove.mCameraWidth / 2)) { fTempW = 1.0f; } float fTempH = 0f; mOriginY = -GetRealFloat(mCameraMove.mCameraHeight / 2); if (Mathf.Abs(mOriginY) > Mathf.Abs(mCameraMove.mCameraHeight / 2)) { fTempH = 1.0f; } List <NetData> netDataList = NetDataManager.GetNetDataList(mOriginX, mOriginY, mCameraMove.mCameraWidth + fTempW, mCameraMove.mCameraHeight + fTempH); if (netDataList != null) { mCurNetDataList.AddRange(netDataList); } /*绘制地图*/ DrawMap(netDataList); }
private static VenderModel SplitVenderInfo(string content) { VenderModel model = new VenderModel(); GroupCollection venderCol = RegexUtils.Match(content, "class=\"cell-supplier\">[\\s\\n]*<a href=\"/browse/shop_home.htm\\?supplierId=(?<id>\\d+?)\"[^>]*>(?<name>.*?)</a>"); model.ID = venderCol["id"].Value; model.Name = venderCol["name"].Value; string shortNameHtml = NetDataManager.GetContent(content, "<td", "class=\"cell-supplier\">", "</td>"); shortNameHtml = Regex.Replace(shortNameHtml, "<[^<>]+>", "-_-"); string[] shortArray = shortNameHtml.Split(new string[] { "-_-" }, StringSplitOptions.RemoveEmptyEntries); for (int i = shortArray.Length - 1; i >= 0; i--) { string tmp = shortArray[i].Trim(); if (!string.IsNullOrEmpty(tmp)) { model.ShortName = tmp; break; } } model.ProductUrl = RegexUtils.Match(content, "<td class=\"cell-mode\">[\\s\\n]*代销\\(<a href=\"(?<url>.*?)\">产品目录</a>\\)")["url"].Value; #region 开始结束时间 string date = RegexUtils.Match(content, "<td class=\"cell-start\">[\\s\\n]*(?<date>.*至.*)[\\s\\n]*</td>")["date"].Value; string[] dateArray = date.Split(new char[] { '至' }, StringSplitOptions.RemoveEmptyEntries); if (dateArray.Length > 0) { model.FromDate = dateArray[0]; } if (dateArray.Length > 1) { model.EndDate = dateArray[1].Trim(); } #endregion model.Status = RegexUtils.Match(content, "<td class=\"cell-status\">[\\s\\n]*<p><em>(?<status>.*?)</em></p>")["status"].Value; return(model); }
public static List <VenderModel> GetVender(string content) { List <VenderModel> list = new List <VenderModel>(); string table = NetDataManager.GetContent(content, "J_Relationship", ">", "</table>"); const string tr = "<tr>"; const string endstr = "<tr class=\"row-sp\">"; int index = table.IndexOf(tr); while (index != -1) { string tmp; int endIndex = table.IndexOf(endstr, index + tr.Length); if (endIndex == -1) { tmp = table.Substring(index); } else { tmp = table.Substring(index, endIndex - index); } VenderModel model = SplitVenderInfo(tmp); if (model != null) { list.Add(model); } index = endIndex; } return(list); }
public static string GetNewTitle(string title, string vender) { string newTitle = string.Empty; string url = string.Format("http://s.taobao.com/search?q={0}&app=detail", HttpUtility.UrlEncode(title, Context.HttpEncoding)); string content = NetDataManager.GetString(url); string body = NetDataManager.GetContent(content, "class=\"tb-content\"", "class=\"row grid-view newsrp-gridcontent-el\"", "<div class=\"tb-bottom\">"); string tmallTongKuanUrl = null; string tongkuanUrl = null; const string find = "<div class=\"col item st-item"; int index = body.IndexOf(find); while (index != -1) { int endIndex = body.IndexOf(find, index + find.Length); string tmp; if (endIndex == -1) { tmp = body.Substring(index); } else { tmp = body.Substring(index, endIndex - index); } string matchString = "\\<div class=\"similar-btns\"\\>\\n*\\s*\\<span class=\"devide-line\"\\>\\<\\/span\\>\\n*\\s*\\<a target=\"_blank\" href=\"(?<url>.*?)\""; Match match = Regex.Match(tmp, matchString); if (match.Success) { string tmpTongkuanUrl = match.Groups["url"].Value; if (tmp.Contains("icon-service-tianmao")) { if (tmallTongKuanUrl == null) { tmallTongKuanUrl = tmpTongkuanUrl; } } else { // success Match venderMatch = Regex.Match(tmp, "<div class=\"col seller[^>]*>[\\s\\n]*<a[^>]*>(?<name>.*?)</a>"); if (venderMatch.Success) { if (venderMatch.Groups["name"].Value.Trim() == vender) { tongkuanUrl = tmpTongkuanUrl; break; } } } } index = endIndex; } //if (string.IsNullOrEmpty(tongkuanUrl)) //{ // tongkuanUrl = tmallTongKuanUrl; //} if (!string.IsNullOrEmpty(tongkuanUrl)) { newTitle = GetTongKuan(url, tongkuanUrl); } if (!string.IsNullOrEmpty(newTitle)) { newTitle = newTitle.Replace("包邮", string.Empty); } return(newTitle); }
private static string GetTongKuan(string mainUrl, string url) { string newTitle = string.Empty; url += "&promote=0&sort=sale-desc&tab=all"; string content; NetDataManager.mainUrl = new Uri(mainUrl); if (NetDataManager.GetMainPage(url, out content)) { string body = NetDataManager.GetContent(content, "class=\"tb-content\"", "class=\"list-view newsrp-i2i-listcontent-el\"", "<div class=\"tb-bottom\">"); string lastTmallTitle = null; const string find = "<div class=\"row item"; int index = body.IndexOf(find); while (index != -1) { string tmp; int endIndex = body.IndexOf(find, index + find.Length); if (endIndex == -1) { tmp = body.Substring(index); } else { tmp = body.Substring(index, endIndex - index); } string matchString = "<h3 class=\"summary\">\\n*\\s*\\<a[^>]+>\\n*\\s*(?<title>.*?)\\n*\\s*</a>"; Match match = Regex.Match(tmp, matchString); if (match.Success) { Match tmallMatch = Regex.Match(tmp, "<div class=\"elem-level\">[\\s\\n]*<a href=\"http://www.tmall.com\""); bool isTmall = tmallMatch.Success; if (isTmall) { if (lastTmallTitle == null) { lastTmallTitle = match.Groups["title"].Value; } } else { newTitle = match.Groups["title"].Value; } } if (!string.IsNullOrEmpty(newTitle)) { break; } index = body.IndexOf(find, index + find.Length); } if (string.IsNullOrEmpty(newTitle) && !string.IsNullOrEmpty(lastTmallTitle)) { newTitle = lastTmallTitle; } } return(newTitle); }