Example #1
0
        static void Main(string[] args)
        {
            // host config
            // 127.0.0.1 cache.spider.com
            if (RedisContext.RedisDatabase == null)
            {
                try
                {
                    RedisContext.RedisDatabase = ConnectionMultiplexer.Connect("cache.spider.com").GetDatabase();
                }
                catch (Exception exception)
                {
                    Console.WriteLine(exception);
                    return;
                }
            }

            try
            {
                var localSpiderEngine = new LocalSpiderEngine();

                //初始化引擎组件
                localSpiderEngine.AddPipelineHandle(new ActiveMQPipelineHandle());

                //种子请求地址
                if (args != null && args.Length >= 3)
                {
                    var request = GetParamRequest(args);

                    SchedulerManage.Instance.Push(request);
                }

                //启动抓取引擎,自我循环运行
                localSpiderEngine.Start();

                while (true)
                {
                    Thread.Sleep(10000);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }