Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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);
        }