Exemplo n.º 1
0
        /// <summary>
        /// 执行主站技巧
        /// </summary>
        private void DoMainUrl()
        {
            List <string>    urls         = GetMainUrl(Config);
            LotteryNewsModel lotterySkill = null;

            foreach (string url in urls)
            {
                List <LotteryNewsModel> res = GetOpenListFromMainUrl(url);

                foreach (var LotteryNewsModel in res)

                {
                    if (LotteryNewsModel.Content != null)
                    {
                        if (services.LotteryNewsModel(currentLottery, LotteryNewsModel))
                        {
                            //Do Success Log
                            log.Info(GetType(), CommonHelper.GetJobMainLogInfo(Config, LotteryNewsModel.Title));

                            isGetData = true;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据主站url获取技巧详情
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        private LotteryNewsModel GetSkillModel(string url)
        {
            LotteryNewsModel lotterySkill = new LotteryNewsModel();

            try
            {
                var htmlResource = NetHelper.GetUrlResponse(url, Encoding.GetEncoding("utf-8"));
                if (htmlResource == null)
                {
                    return(lotterySkill);
                }

                HtmlDocument doc = new HtmlDocument();
                doc.LoadHtml(htmlResource);

                //获取li下面所有a标签
                var div = doc.DocumentNode.SelectSingleNode("//*[@class='news_content']");

                var    Title   = div.ChildNodes.Where(node => node.Name == "h2").ToList();
                var    div1    = div.ChildNodes.Where(node => node.Name == "div").ToList();
                string txt     = div1[2].InnerHtml.Trim();
                var    Content = txt.Replace("<img src=\"", " <img src=\"http://www.zhcw.com").Replace("中彩网讯", "").Replace("中彩网综合报道", "综合报道").Replace("中彩网", "");
                if (Content == "")
                {
                    Content = null;
                }



                lotterySkill.Title     = Title[0].InnerText.Trim();
                lotterySkill.Author    = "cn55128";
                lotterySkill.Content   = Content;
                lotterySkill.IsDelete  = false;
                lotterySkill.SourceUrl = url.ToString();
                lotterySkill.TypeID    = lotterySkillType;
                lotterySkill.TypeName  = lotterySkillType.GetEnumDescription();
            }
            catch (Exception ex)
            {
                log.Error(GetType(),
                          string.Format("【{0}】通过主抓取开奖列表时发生错误,错误信息【{1}】", Config.Area + currentLottery, ex.Message));
            }
            return(lotterySkill);
        }