Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="url"></param>
        public List <GameNode> PostHtmlGameNode(string url)
        {
            PubilcHtml      pubilcHtml = new PubilcHtml();
            List <GameNode> gameNodes  = new List <GameNode>();
            var             results    = pubilcHtml.ReturnHtmlNode(url, indexOne);

            foreach (var item in results)
            {
                GameNode gameNode = new GameNode();
                gameNode.GameTypeName = item.InnerHtml.Trim();
                gameNodes.Add(gameNode);
            }
            return(gameNodes);
        }
        /// <summary>
        /// 解析URL返回对应标签数据
        /// </summary>
        /// <returns></returns>
        public Dictionary <int, HtmlNodeCollection> GetGameHtmlInfo()
        {
            PubilcHtml pubilcHtml    = new PubilcHtml();
            var        gameHtmlInfos = _gameHtmlInfoServer.GetAll();
            Dictionary <int, HtmlNodeCollection> htmlNodes = new Dictionary <int, HtmlNodeCollection>();
            HtmlNodeCollection result = new HtmlNodeCollection(null);

            if (gameHtmlInfos != null)
            {
                for (int i = 1; i <= 23; i++)
                {
                    var html      = gameHtmlInfos[0].HtmlUrl.Replace("e378", string.Format("e378?page={0}", i));
                    var nodeLists = pubilcHtml.ReturnHtmlNode(html, indexTwo);
                    foreach (var node in nodeLists)
                    {
                        result.Append(node);
                    }
                }

                var gameList = gameHtmlInfos.Skip(1);
                foreach (var item in gameList)
                {
                    var gameHtmlType = item.HtmlUrl.Substring(27);
                    for (int i = 1; i < 400; i++)
                    {
                        GameStrategy gameStrategy = new GameStrategy();
                        var          JsonApi      = String.Format("https://www.taptap.com/ajax/search/tags?&kw={0}&sort=hits&page={1}", gameHtmlType, i);
                        var          temp         = HttpGet(JsonApi, keyValues);
                        JsonHelp     jsonHelp     = new JsonHelp();
                        var          tempValue    = jsonHelp.JsonToObj <GameJson>(temp);
                        var          htmlContent  = "";
                        if (tempValue.Data.Html.Contains("img"))
                        {
                            var htmlContentone = tempValue.Data.Html.Replace("<img", "<img style='width:150px;height:150px;margin-top:10px'");
                            var htmlContentTwo = htmlContentone.Replace("app-card-right app-tag-right", "pull-right col-md-7");
                            htmlContent = htmlContentTwo.Replace("btn btn-xs btn-default", "btn btn-xs btn-info");
                        }
                        gameStrategy.content    = htmlContent;
                        gameStrategy.GameNodeID = item.GameNodeId.GetValueOrDefault();
                        gameStrategy.CreateTime = DateTime.Now;
                        Save(gameStrategy);
                    }
                }
                htmlNodes.Add(gameHtmlInfos[0].GameNodeId.GetValueOrDefault(), result);
            }
            return(htmlNodes);
        }