Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }