Exemple #1
0
        protected virtual GameAccountItem GetWowAccountItemFromHtml(string accountHtml)
        {
            if (!string.IsNullOrEmpty(accountHtml))
            {
                string url = HtmlParser.GetOutterPropertyFromHtml(accountHtml, "href");
                if (url.Contains("amp;"))
                {
                    url = url.Replace("amp;", "");
                }
                //May be contains <span > in account_id <span>
                string id = HtmlParser.GetInnerTextFromHtml(HtmlParser.GetOuterTextFromHtml("<span class=\"account-id>", " <", 1, accountHtml)).Trim();

                if (string.IsNullOrEmpty(id))
                {
                    id = HtmlParser.GetInnerTextFromHtml(HtmlParser.GetOuterTextFromHtml("<span class=\"account-id", "</span>", 1, accountHtml)).Trim();
                }
                string edition = HtmlParser.GetInnerTextFromHtml(HtmlParser.GetOuterTextFromHtml("<span class=\"account-edition", "</span>", 1, accountHtml)).Trim();
                string region  = HtmlParser.GetInnerTextFromHtml(HtmlParser.GetOuterTextFromHtml("<span class=\"account-region", "</span>", 1, accountHtml)).Trim();
                id.Replace("[", "");
                id.Replace("]", "");

                GameAccountItem gameItem = new GameAccountItem()
                {
                    Name = id, Edition = edition, Region = region, DetailUrl = url
                };
                return(gameItem);
            }

            return(null);
        }
Exemple #2
0
        protected virtual GameAccountItem GetD3AccountItemFromHtml(string accountHtml)
        {
            //<span class="account-link">
            //<strong>
            //<a href="/account/management/d3/dashboard.html">
            //《暗黑破壞神?III》
            //</a>
            //</strong>
            //<span class="account-id"><span class="account-edition">標準版</span></span>
            //</span>

            //<span class="account-link">
            //<strong>
            //<a href="/account/management/digital-purchase.html?product=D3">
            //立即購買《暗黑破壞神?III》!
            //</a>
            //</strong>
            //</span>


            if (!string.IsNullOrEmpty(accountHtml))
            {
                string          linkStr  = HtmlParser.GetInnerTextFromHtml(HtmlParser.GetOuterTextFromHtml("<a href=\"/account/management/", "</a>", 1, accountHtml)).Trim();
                string          edition  = HtmlParser.GetInnerTextFromHtml(HtmlParser.GetOuterTextFromHtml("<span class=\"account-edition", "</span>", 1, accountHtml)).Trim();
                GameAccountItem gameItem = new GameAccountItem()
                {
                    Detail = string.Format("{0} - {1}", linkStr, string.IsNullOrEmpty(edition)?"无效":edition)
                };
                return(gameItem);
            }

            return(null);
        }
Exemple #3
0
        /// <summary>
        /// 列出有多少个子帐号,不再进一步查明细
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        protected virtual IList <GameAccountItem> GetGameAccountItemList(string content)
        {
            //<ul id="game-list-wow">
            IList <GameAccountItem> gameAccountList = new List <GameAccountItem>();

            //Get D3 accounts
            string d3ListContent = HtmlParser.GetOuterTextFromHtml("<ul id=\"game-list-d3\">", "</ul>", 1, content);

            if (!string.IsNullOrEmpty(d3ListContent))
            {
                while ((d3ListContent.IndexOf("<li class=\"border-4") > 0) ||
                       (d3ListContent.IndexOf("<li class=\"disabled unloaded border-4") > 0))
                {
                    string gameContent = HtmlParser.GetOuterTextFromHtml("<li class=\"border-4", "</li>", 1, d3ListContent);
                    if (string.IsNullOrEmpty(gameContent))
                    {
                        gameContent = HtmlParser.GetOuterTextFromHtml("<li class=\"disabled unloaded border-4", "</li>", 1, d3ListContent);
                    }

                    if (!string.IsNullOrEmpty(gameContent))
                    {
                        GameAccountItem item = this.GetD3AccountItemFromHtml(gameContent);
                        if (null != item)
                        {
                            gameAccountList.Add(item);
                        }
                        d3ListContent = d3ListContent.Replace(gameContent, "");
                    }
                }
            }

            //Get wow accounts
            string wowListContent = HtmlParser.GetOuterTextFromHtml("<ul id=\"game-list-wow", "</ul>", 1, content);

            if (!string.IsNullOrEmpty(wowListContent))
            {
                while ((wowListContent.IndexOf("<li class=\"border-4") > 0) ||
                       (wowListContent.IndexOf("<li class=\"disabled unloaded border-4") > 0))
                {
                    string gameContent = HtmlParser.GetOuterTextFromHtml("<li class=\"border-4", "</li>", 1, wowListContent);
                    if (string.IsNullOrEmpty(gameContent))
                    {
                        gameContent = HtmlParser.GetOuterTextFromHtml("<li class=\"disabled unloaded border-4", "</li>", 1, wowListContent);
                    }
                    if (!string.IsNullOrEmpty(gameContent))
                    {
                        GameAccountItem item = this.GetWowAccountItemFromHtml(gameContent);
                        if (null != item)
                        {
                            gameAccountList.Add(item);
                        }
                        wowListContent = wowListContent.Replace(gameContent, "");
                    }
                }
            }

            return(gameAccountList);
        }
Exemple #4
0
 protected override string GetGameAccountDetail(GameAccountItem accountItem)
 {
     if ((null != accountItem) && !string.IsNullOrEmpty(accountItem.DetailUrl))
     {
         string content = this.ReadFromUrl(accountItem.DetailUrl);
         if (!string.IsNullOrEmpty(content))
         {
             return(ParseGameAccountDetail(content).Trim());
         }
     }
     return(string.Empty);
 }
Exemple #5
0
        protected virtual string GetGameAccountDetail(GameAccountItem accountItem)
        {
            #region HtmlSampleCode

            //https://us.battle.net/account/management/wow/dashboard.html?region=US&accountName=COMRVF&ST=US-575779-Kpe1pnm5TCCvZfGYu6PeLZbEv2pWzbdRJCf

            #endregion HtmlSampleCode

            HttpWebRequest httpRequest = this.GetHttpWebRequest(accountItem.DetailUrl, true);
            if (null != httpRequest)
            {
                try
                {
                    string content = this.ReadFromHttpWebResponse(httpRequest);
                    return(ParseGameAccountDetail(content).Trim());
                }
                finally
                {
                    this.DisposeHttpRequest(httpRequest);
                }
            }
            return(string.Empty);
        }