コード例 #1
0
ファイル: ActivityCollectors.cs プロジェクト: abuq/Collection
        /// <summary>
        /// ParseCurrentItems
        /// </summary>
        /// <returns></returns>
        protected override IResut[] ParseCurrentItems()
        {
            var resultList   = new List <IResut>();
            var itemList     = GetItemList(CurrentUrl);
            var activityType = _acvivityEnum.GetType();



            foreach (var item in itemList)
            {
                var dic = GetInformationByJson(item);


                IResut resut = new Resut()
                {
                    { "title", dic["title"] },
                    { "description", dic["description"] },
                    { "itemId", dic["itemId"] },
                    { "ostimeText", dic["ostimeText"] },
                    { "leftTime", dic["leftTime"] },
                    { "totalStock", dic["totalStock"] },
                    { "soldAmount", dic["soldAmount"] },
                    { "itemUrl", dic["itemUrl"] },
                    { "actPrice", dic["actPrice"] },
                    { "origPrice", dic["origPrice"] },
                    { "discount", dic["discount"] },
                    { "type", _acvivityEnum.ToString() }
                };



                resultList.Add(resut);
            }

            return(resultList.ToArray());
        }
コード例 #2
0
ファイル: TejiaCollectors.cs プロジェクト: abuq/Collection
        /// <summary>
        /// 为第一页作初始化准备
        /// </summary>
        /// <param name="param">The parameter.</param>
        /// <returns>System.String.</returns>
        /// <exception cref="System.Exception">url链接错误。</exception>
        protected override string InitFirstUrl(ActivityParameter param)
        {
            var url = param.Url;

            if (url.Equals("http://tejia.taobao.com"))
            {
                _acvivityEnum = AcvivityEnum.TeJia;
            }
            else if (url.Equals("http://tejia.taobao.com/ten.htm"))
            {
                _acvivityEnum = AcvivityEnum.TeJiaTen;
            }
            else if (url.Equals("http://tejia.taobao.com/jinribaokuan.htm"))
            {
                _acvivityEnum = AcvivityEnum.TejiaJinRiBaoKuan;
            }
            else if (url.Equals("http://www.taobao.com/markets/tejia/tehuitunnew"))
            {
                _acvivityEnum = AcvivityEnum.TejiaTeHuiTunNew;
            }
            else if (url.Equals("https://taojinbi.taobao.com"))
            {
                _acvivityEnum = AcvivityEnum.TaoJinBi;
            }
            else
            {
                throw new Exception("url链接错误。");
            }

            if (_acvivityEnum.ToString().Equals("TeJia") ||
                _acvivityEnum.ToString().Equals("TeJiaTen") ||
                _acvivityEnum.ToString().Equals("TejiaJinRiBaoKuan"))
            {
                _homePage = "http://tejia.taobao.com";
            }
            else if (_acvivityEnum.ToString().Equals("TejiaTeHuiTunNew"))
            {
                _homePage = "http://www.taobao.com/markets/tejia/tehuitunnew";
            }
            else if (_acvivityEnum.ToString().Equals("TaoJinBi"))
            {
                _homePage = "https://taojinbi.taobao.com";
            }

            GetDataUrlQueue(_homePage);

            return(_dataUrlQueue.Count != 0 ? _dataUrlQueue.Dequeue() : null);
        }