示例#1
0
        private void TestWeb()
        {
            BaseParser bp = ParseFactory.GetParser(SportID.SID_ESPORT, StaticData.webNames[(int)WebID.WID_BTI]);

            bp.showLogEvent = ShowLog;
            bp.LoadStaticData();
            ShowLog(string.Format("爬取分析网站:{0}", StaticData.webNames[(int)bp.webID]));
            bp.GrabAndParseHtml();
        }
示例#2
0
        private void Start()
        {
            List <Thread> threads = new List <Thread>();

            while (true)
            {
                List <string> webs = Util.GetFilesCount(configDir + "\\" + StaticData.sportNames[(int)SportID.SID_ESPORT], "*.ini");
                ShowLog("-------------------------------");
                ShowLog(string.Format("循环第{0}次,爬取{1}个网站...", ++time, webs.Count));
                List <BetItem> total = new List <BetItem>();
                threads.Clear();
                ESportParser.LoadMainData();
                ShowLog(string.Format("加载主列表队列..."));
                for (int i = 0; i < webs.Count; i++)
                {
                    int    x = i;
                    Thread s = new Thread(() => {
                        BaseParser bp   = ParseFactory.GetParser(SportID.SID_ESPORT, webs[x]);
                        bp.showLogEvent = ShowLog;
                        bp.LoadStaticData();
                        if (bp.bIsEffect)
                        {
                            ShowLog(string.Format("线程{0},爬取分析网站:{1}", x.ToString(), StaticData.webNames[(int)bp.webID]));
                            bp.GrabAndParseHtml();
                            total.AddRange(bp.betItems);
                        }
                        else
                        {
                            ShowLog(string.Format("线程{0},爬取分析网站:{1} 配置读取错误!", x.ToString(), StaticData.webNames[(int)bp.webID]));
                        }
                    });
                    s.Name         = StaticData.webNames[i];
                    s.IsBackground = true;
                    s.Start();
                    threads.Add(s);
                }

                for (int i = 0; i < webs.Count; i++)
                {
                    threads[i].Join();
                }

                var pair   = BaseParser.ParseBetWin(total);
                var finals = FilterResult(pair);
                ShowResult(finals);

                //延迟时间
                if (!string.IsNullOrEmpty(tbSleepTime.Text))
                {
                    Thread.Sleep(Convert.ToInt32(tbSleepTime.Text) * 1000);
                }
            }
        }