Example #1
0
        /// <summary>
        /// 打开指定平台一个页面
        /// </summary>
        /// <param name="platform"></param>
        private void OpenTabPlatformMenuToolStrip(SupportPlatformEnum platform)
        {
            var siteObj = GlobalContext.SupportPlatforms.Find(x => x.Platform == platform);

            if (null == siteObj)
            {
                string platformDescription = platform.GetEnumDescription();
                MessageBox.Show($"未能正确从配置文件加载平台地址:{platformDescription ?? platform.ToString()}");
                return;
            }

            this.NewTab(siteObj.SiteUrl);
        }
        /// <summary>
        /// 拉取发送cookie到redis
        /// </summary>
        /// <param name="platform"></param>
        /// <param name="cookies"></param>
        public static List <CefCookie> PullFromRedisCookies(SupportPlatformEnum platform)
        {
            var siteObj = GlobalContext.SupportPlatforms.Find(x => x.Platform == platform);

            if (null == siteObj)
            {
                string platformDescription = platform.GetEnumDescription();
                string errMsg = string.Format($"CrawlerCookiesPopJob,未能正确从配置文件加载平台地址:{platformDescription ?? platform.ToString()}");
                throw new Exception(errMsg);
            }
            //键
            return(PullFromRedisCookies(siteObj.SiteUrl));
        }
        /// <summary>
        /// 从远程客户端 获取平台Cookie
        /// </summary>
        /// <returns></returns>

        protected virtual List <CefCookie> GetCookiesFromRemoteRedisServer(SupportPlatformEnum platform)
        {
            List <CefCookie> result = null;

            try
            {
                var cks_Platform = GlobalContext.PullFromRedisCookies(platform);
                if (null == cks_Platform || cks_Platform.IsEmpty())
                {
                    return(result);
                }

                result = cks_Platform;
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }

            return(result);
        }
Example #4
0
        /// <summary>
        /// 根据不同的平台类型
        /// 创建对应平台的蜘蛛实例
        /// 工厂分支
        /// </summary>
        /// <param name="platform"></param>
        /// <returns></returns>
        public static BaseWebPageService CreateWebPageService(SupportPlatformEnum platform)
        {
            BaseWebPageService webPageService = null;

            switch (platform)
            {
            case SupportPlatformEnum.Tmall:
                webPageService = new TmallWebPageService();
                break;

            case SupportPlatformEnum.Taobao:
                webPageService = new TaobaoWebPageService();
                break;

            case SupportPlatformEnum.Jingdong:
                webPageService = new JingdongWebPageService();
                break;

            case SupportPlatformEnum.Pdd:
                webPageService = new PddWebPageService();
                break;

            case SupportPlatformEnum.Vip:
                webPageService = new VipWebPageService();
                break;

            case SupportPlatformEnum.Guomei:
                webPageService = new GuomeiWebPageService();
                break;

            case SupportPlatformEnum.Suning:
                webPageService = new SuningWebPageService();
                break;

            case SupportPlatformEnum.Dangdang:
                webPageService = new DangdangWebPageService();
                break;

            case SupportPlatformEnum.Yhd:
                webPageService = new YhdWebPageService();
                break;

            //case SupportPlatformEnum.Meilishuo:
            //    webPageService = new MeilishuoWebPageService();
            //    break;
            case SupportPlatformEnum.Mogujie:
                webPageService = new MogujieWebPageService();
                break;

            //case SupportPlatformEnum.Zhe800:
            //    webPageService = new Zhe800WebPageService();
            //    break;
            case SupportPlatformEnum.ETao:
                webPageService = new ETaoWebPageService();
                break;

            default:
                break;
            }

            return(webPageService);
        }
        /// <summary>
        /// 获取指定平台的商品搜索解析器
        /// 需要以插件的形式加载解析器
        /// 解析内容时刻可能不断的调整,但是站点不能一直编译发布,不能因为发布某个插件就停止站点
        /// </summary>
        /// <param name="platform"></param>
        /// <returns></returns>
        public static ISearchProductResolver GetSearchProductResolver(SupportPlatformEnum platform)
        {
            ISearchProductResolver resolver = null;

            switch (platform)
            {
            case SupportPlatformEnum.Tmall:
                resolver = new TmallSearchProductResolver();
                break;

            case SupportPlatformEnum.Taobao:
                resolver = new TaobaoSearchProductResolver();

                break;

            case SupportPlatformEnum.Jingdong:
                resolver = new JingdongSearchProductResolver();

                break;

            case SupportPlatformEnum.Pdd:
                resolver = new PddSearchProductResolver();

                break;

            case SupportPlatformEnum.Vip:
                resolver = new VipSearchProductResolver();

                break;

            case SupportPlatformEnum.Guomei:
                resolver = new GuomeiSearchProductResolver();
                break;

            case SupportPlatformEnum.Suning:
                resolver = new SuningSearchProductResolver();

                break;

            case SupportPlatformEnum.Dangdang:
                resolver = new DangdangSearchProductResolver();

                break;

            case SupportPlatformEnum.Yhd:
                resolver = new YhdSearchProductResolver();

                break;
            //case SupportPlatformEnum.Meilishuo:
            //    resolver = new MeilishuoSearchProductResolver();

            //    break;
            case SupportPlatformEnum.Mogujie:
                resolver = new MogujieSearchProductResolver();

                break;

            case SupportPlatformEnum.ETao:
                resolver = new ETaoSearchProductResolver();

                break;

            default:
                throw new Exception(string.Format("未能找到指定平台的商品解析器!不支持该平台:{0}", platform.ToString()));
            }

            return(resolver);
        }