Пример #1
0
        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);
        }
Пример #2
0
        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);
        }