public override List <GoodList> parse()
        {
            List <GoodList> mList      = new List <GoodList>();
            MatchCollection mcTitle    = Regex.Matches(html, @"(?<=<DT><A title=).*(?=.href)");
            MatchCollection mcIntegral = Regex.Matches(html, @"(?<=&nbsp;<SPAN>).*(?=</SPAN>)|(?<=兑换积分:<SPAN>).*(?=</SPAN>分)");

            MatchCollection mcImgUrl      = Regex.Matches(html, @"(?<=src="").*(?="".width=120)");
            MatchCollection mcDetailedUrl = Regex.Matches(html, @"(?<=href="").*(?="".target=_blank><IMG.alt)");

            int    count = mcTitle.Count;
            int    count_for_integral = mcIntegral.Count;
            string title        = "";
            string detailed_url = "";
            string integral     = "";
            string no           = "";
            string imgUrl       = "";
            string cash         = "0";

            for (int i = 0, j = 0; i < count; i++, j++)
            {
                //解析title
                title = mcTitle[i].ToString();

                //解析detailed url
                detailed_url = "http://ccclub.cmbchina.com/ccclubnew/" + mcDetailedUrl[i].ToString();

                string          htmlText = CommonHttp.HttpGet(detailed_url);
                MatchCollection mcNo     = Regex.Matches(htmlText, @"(?<=<td><b>)\d*(?=</b>)");
                //解析编号
                no = mcNo[0].ToString();

                //解析积分
                integral = mcIntegral[j].ToString();
                cash     = "0";
                if (j + 1 < count_for_integral)
                { //解析现金
                    string next_integral = mcIntegral[j + 1].ToString();
                    if (next_integral.Trim().StartsWith("¥"))
                    {
                        cash = next_integral.Replace("¥", "");
                        ++j;
                    }
                }
                integral = integral.Trim();

                //解析ImgUrl
                imgUrl = mcImgUrl[i].ToString().Trim();

                GoodList mGoodList = new GoodList();
                mGoodList.Title       = StringHelper.StringProc(title);
                mGoodList.Integral    = integral;
                mGoodList.No          = no;
                mGoodList.ImgUrl      = imgUrl;
                mGoodList.DetailedUrl = detailed_url;
                mGoodList.Cash        = cash;
                mList.Add(mGoodList);
            }
            return(mList);
        }
Ejemplo n.º 2
0
        private void add(GoodList good)
        {
            good.Typeid = selectedValue;
            string executeString = string.Format("INSERT INTO `tb_good`(good_name,good_integral,good_no,good_imgurl,good_detailedurl,good_typeid,good_cash) VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', {5},'{6}')",
                                                 good.Title, good.Integral, good.No, good.ImgUrl, good.DetailedUrl, good.Typeid, good.Cash);

            DBHelper.ExecuteCommand(executeString);
        }
        public override List <GoodList> parse()
        {
            List <GoodList> mList      = new List <GoodList>();
            MatchCollection mcTitle    = Regex.Matches(html, @"(?<=\bonclick=""return false"" href=""#"">).*(?=\b*</A></TD>\r\n<TD class=group_text)");
            MatchCollection mcIntegral = Regex.Matches(html, @"(?<=\bA></TD>\r\n<TD class=group_text align=middle>).*(?=\b*</TD>)");
            MatchCollection mcNo       = Regex.Matches(html, @"(?<=\bonclick=""return false"" href=""#"">).*(?=\b*</A></TD>\r\n<TD class=group_link)");
            MatchCollection mcImgUrl   = Regex.Matches(html, @"(?<=\b*<TR>\r\n<TD class=group_link><A onmouseover=""onMouseOverShowImg\(').*(?=\b*')");
            MatchCollection mcCash     = Regex.Matches(html, @"(?<=align=middle>).*(?=</TD>\r\n<TD.*class=group_text align=middle><INPUT)");

            int count = mcTitle.Count;

            for (int i = 0; i < count; i++)
            {
                //解析title
                string title = mcTitle[i].ToString();

                //解析积分
                string integral = mcIntegral[i].ToString();

                //解析编号
                string no = mcNo[i].ToString();

                //解析ImgUrl
                string imgUrl = mcImgUrl[i].ToString();
                imgUrl = "https://iservice.boccc.com.hk" + imgUrl;

                string cash = mcCash[i].ToString();

                GoodList mGoodList = new GoodList();
                mGoodList.Title       = title;
                mGoodList.Integral    = integral;
                mGoodList.No          = no;
                mGoodList.ImgUrl      = imgUrl;
                mGoodList.DetailedUrl = "";
                mGoodList.Cash        = cash;
                mList.Add(mGoodList);
            }
            return(mList);
        }
        public override List <GoodList> parse()
        {
            List <GoodList> mList         = new List <GoodList>();
            MatchCollection mcTitle       = Regex.Matches(html, @"(?<=\bclass=Name><A title=).*(?=\bhref=)");
            MatchCollection mcIntegral    = Regex.Matches(html, @"(?<=\bSPAN class=GPriceRed>).*(?=\b</SPAN>)");
            MatchCollection mcNo          = Regex.Matches(html, @"(?<=\b񅧏: ).*(?=\b</DIV>)");
            MatchCollection mcImgUrl      = Regex.Matches(html, @"(?<=\bsrc="").*(?=""></A></DIV>)");
            MatchCollection mcDetailedUrl = Regex.Matches(html, @"(?<=\bhref="").*(?=""\s+target=_blank><IMG)");

            int count = mcTitle.Count;

            for (int i = 0; i < count; i++)
            {
                //½âÎötitle
                string title = mcTitle[i].ToString();

                //½âÎö»ý·Ö
                string integral = mcIntegral[i].ToString();
                integral = integral.Replace(",", "");
                //½âÎö±àºÅ
                string no = mcNo[i].ToString();

                //½âÎöImgUrl
                string imgUrl = mcImgUrl[i].ToString();

                //½âÎöDetailedUrl
                string   detailedUrl = mcDetailedUrl[i].ToString();
                GoodList mGoodList   = new GoodList();
                mGoodList.Title       = title;
                mGoodList.Integral    = integral;
                mGoodList.No          = no;
                mGoodList.ImgUrl      = imgUrl;
                mGoodList.DetailedUrl = detailedUrl;
                mList.Add(mGoodList);
            }
            return(mList);
        }
        public override List <GoodList> parse()
        {
            List <GoodList> mList         = new List <GoodList>();
            MatchCollection mcTitle       = Regex.Matches(html, @"(?<=\bIMG alt=).*(?=\b*src)");
            MatchCollection mcIntegral    = Regex.Matches(html, @"(?<=\btxt_bg_jinbi\>\<SPAN class=c_e\>\<SPAN class=fwb>).*(?=\b\<\/SPAN\>分)");
            MatchCollection mcNo          = Regex.Matches(html, @"(?<=\btitle="""" href=""../product_).*(?=\b.html)");
            MatchCollection mcImgUrl      = Regex.Matches(html, @"(?<=\bsrc="").*(?=\b"">\s+</A></DIV>\r\n<DIV class=pro_name)");
            MatchCollection mcDetailedUrl = Regex.Matches(html, @"(?<=\btitle="""" href=""..).*(?=\b=""\s+target=_blank)");
            int             count         = mcTitle.Count;

            for (int i = 0; i < count; i++)
            {
                //解析title
                string title = mcTitle[i].ToString().Replace("\"", "");

                //解析积分
                string integral = mcIntegral[i].ToString();
                integral = integral.Equals(",", "");
                //解析编号
                string no = mcNo[i].ToString();

                //解析ImgUrl
                string imgUrl = mcImgUrl[i].ToString();

                //解析DetailedUrl
                string   detailedUrl = "http://www.wanlitong.com" + mcDetailedUrl[i].ToString();
                GoodList mGoodList   = new GoodList();
                mGoodList.Title       = title;
                mGoodList.Integral    = integral;
                mGoodList.No          = no;
                mGoodList.ImgUrl      = imgUrl;
                mGoodList.DetailedUrl = detailedUrl;
                mList.Add(mGoodList);
            }
            return(mList);
        }