当前位置: 首页>>代码示例>>C#>>正文


C# HtmlDocument.LoadHtml2方法代码示例

本文整理汇总了C#中HtmlAgilityPack.HtmlDocument.LoadHtml2方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlDocument.LoadHtml2方法的具体用法?C# HtmlDocument.LoadHtml2怎么用?C# HtmlDocument.LoadHtml2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HtmlAgilityPack.HtmlDocument的用法示例。


在下文中一共展示了HtmlDocument.LoadHtml2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetNicoRepo

        //ニコレポ取得
        public IList<NicoNicoNicoRepoDataEntry> GetNicoRepo()
        {
            //APIと言うのか謎
            var api = PrevUrl = @"http://www.nicovideo.jp/my/top/" + Id + @"?innerPage=1&mode=next_page";

            //html
            var html = NicoNicoWrapperMain.GetSession().GetAsync(api).Result;

            IList<NicoNicoNicoRepoDataEntry> data = new List<NicoNicoNicoRepoDataEntry>();

            //XPathでhtmlから抜き出す
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml2(html);

            //ニコレポが存在しなかったら存在しないというエントリを返す
            if(doc.DocumentNode.SelectSingleNode("/div[@class='nicorepo']/div[@class='nicorepo-page']/div").Attributes["class"].Value.Equals("empty")) {

                NicoNicoNicoRepoDataEntry entry = new NicoNicoNicoRepoDataEntry();

                entry.ImageUrl = entry.IconUrl = null;
                entry.Description = "ニコレポが存在しません。";
                data.Add(entry);

                return data;
            }

            StoreData(doc, data);

            return data;
        }
开发者ID:S--Minecraft,项目名称:SRNicoNico,代码行数:31,代码来源:NicoNicoNicoRepo.cs

示例2: GetRankingAsync

        public async Task<NicoNicoRankingEntry> GetRankingAsync(string category, int page) {

            try {

                var ret = new NicoNicoRankingEntry();

                ret.Period = Period;
                ret.Target = Target;

                var a = await NicoNicoWrapperMain.Session.GetAsync(string.Format(ApiUrl, category, page));

                var doc = new HtmlDocument();
                doc.LoadHtml2(a);

                ret.ItemList = new List<RankingItem>();

                var nodes = doc.DocumentNode.SelectNodes("//div[@class='contentBody video videoList01']/ul/li");
                if(nodes == null) {

                    return null;
                }

                foreach(var ranking in nodes) {

                    var item = new RankingItem();

                    item.Rank = ranking.SelectSingleNode("div[@class='rankingNumWrap']/p[@class='rankingNum']").InnerText;
                    item.RankingPoint = ranking.SelectSingleNode("div[@class='rankingNumWrap']/p[@class='rankingPt']").InnerText;

                    var wrap = ranking.SelectSingleNode("div[@class='videoList01Wrap']");

                    item.PostAt = wrap.SelectSingleNode("p[contains(@class, 'itemTime')]").InnerText;

                    item.Length = wrap.SelectSingleNode("div[@class='itemThumbBox']/span").InnerText;
                    item.ThumbNail = wrap.SelectSingleNode("div[@class='itemThumbBox']/div/a/img[2]").Attributes["data-original"].Value;

                    var content = ranking.SelectSingleNode("div[@class='itemContent']");

                    item.VideoUrl = "http://www.nicovideo.jp/" + content.SelectSingleNode("p/a").Attributes["href"].Value;
                    item.Title = content.SelectSingleNode("p/a").InnerText;

                    item.Description = content.SelectSingleNode("div[@class='wrap']/p[@class='itemDescription ranking']").InnerText;

                    var itemdata = content.SelectSingleNode("div[@class='itemData']/ul");

                    item.ViewCount = itemdata.SelectSingleNode("li[@class='count view']/span").InnerText;
                    item.CommentCount = itemdata.SelectSingleNode("li[@class='count comment']/span").InnerText;
                    item.MylistCount = itemdata.SelectSingleNode("li[@class='count mylist']/span").InnerText;

                    ret.ItemList.Add(item);
                }

                return ret;
            }catch(RequestTimeout) {

                return null;
            }
        }
开发者ID:mrtska,项目名称:SRNicoNico,代码行数:58,代码来源:NicoNicoRanking.cs

示例3: GetFavoriteCommunity

        public List<NicoNicoFavoriteCommunityContent> GetFavoriteCommunity()
        {
            //無駄にアクセスしないように
            if(IsEnd && Page != 1) {

                return null;
            }

            var url = "http://www.nicovideo.jp/my/community?page=" + Page++;
            var a = NicoNicoWrapperMain.Session.GetAsync(url).Result;

            var ret = new List<NicoNicoFavoriteCommunityContent>();

            var doc = new HtmlDocument();
            doc.LoadHtml2(a);

            var content = doc.DocumentNode.SelectSingleNode("//div[@class='content']");

            var outers = content.SelectNodes("child::div[@class='articleBody']/div[@class='outer']");

            //終了
            if(outers == null) {

                IsEnd = true;
                return null;
            }

            foreach(var entry in outers) {

                var user = new NicoNicoFavoriteCommunityContent();

                var section = entry.SelectSingleNode("child::div[@class='section']");

                user.CommunityPage =  section.SelectSingleNode("child::h5/a").Attributes["href"].Value;
                user.Name = HttpUtility.HtmlDecode(section.SelectSingleNode("child::h5/a").InnerText.Trim());
                user.ThumbnailUrl = entry.SelectSingleNode("child::div[@class='thumbContainer']/a/img").Attributes["src"].Value;

                var p = section.SelectSingleNode("child::p[1]");
                user.VideoAndMember = section.SelectSingleNode("child::ul/li[1]").InnerText.Trim() + " " + section.SelectSingleNode("child::ul/li[2   ]").InnerText.Trim();
                user.Description = p == null ? "" : p.InnerText.Trim();

                //説明がなかったら
                if(user.Description == "ニコレポリストに追加/編集する") {

                    user.Description = "";
                }
                //改行を空白に置換
                user.Description = user.Description.Replace('\n', ' ').Replace('\r', ' ');

                user.Description = HttpUtility.HtmlDecode(user.Description);
                ret.Add(user);
            }
            return ret;
        }
开发者ID:mrtska,项目名称:SRNicoNico,代码行数:54,代码来源:NicoNicoFavoriteCommunity.cs

示例4: Initialize

        public override void Initialize()
        {
            var html = client.DownloadString(Properties.Settings.Default.tieba_url);
            var doc = new HtmlAgilityPack.HtmlDocument();
            doc.LoadHtml2(html);

            var link = doc.DocumentNode.QuerySelectorAll(".listThreadTitle>a").FirstOrDefault();
            var href = link?.Attributes["href"]?.Value;

            Title = link?.InnerText.Trim();
            ThreadId = Path.GetFileName(new Uri(href).LocalPath);
        }
开发者ID:john-guo,项目名称:hodgepodge,代码行数:12,代码来源:BulletSource_Tieba.cs

示例5: GetLiveInformation

        public IList<NicoNicoFavoriteLiveContent> GetLiveInformation()
        {
            try {

                var a = NicoNicoWrapperMain.Session.GetAsync(LiveUrl).Result;

                var doc = new HtmlDocument();
                doc.LoadHtml2(a);

                var content = doc.DocumentNode.SelectSingleNode("//div[@class='content']");

                if(content == null) {

                    return null;
                }

                var outers = content.SelectNodes("child::div[@id='ch']/div/div[@class='outer']");

                //終了
                if(outers == null) {

                    return null;
                }

                var list = new List<NicoNicoFavoriteLiveContent>();

                foreach(var outer in outers) {

                    var entry = new NicoNicoFavoriteLiveContent();

                    entry.CommunityUrl = outer.SelectSingleNode("child::a[1]").Attributes["href"].Value;

                    var img = outer.SelectSingleNode("child::a/img");

                    entry.ThumbNailUrl = img.Attributes["src"].Value;
                    entry.CommunityName = "<a href=\"" + entry.CommunityUrl + "\">" + img.Attributes["alt"].Value + "</a>";

                    var section = outer.SelectSingleNode("child::div");

                    entry.Title = section.SelectSingleNode("child::h5/a").InnerText.Trim();
                    entry.LiveUrl = section.SelectSingleNode("child::h5/a").Attributes["href"].Value;
                    entry.StartTime = section.SelectSingleNode("child::p[@class='time']/small").InnerText;

                    list.Add(entry);
                }

                return list;
            } catch(RequestTimeout) {

                return null;
            }
        }
开发者ID:mrtska,项目名称:SRNicoNico,代码行数:52,代码来源:NicoNicoFavoriteLive.cs

示例6: SelectorBaseTest

 protected SelectorBaseTest()
 {
     string html;
     var assembly = Assembly.GetExecutingAssembly();
     const string resourceName = "Fizzler.Tests.SelectorTest.html";
     using (var stream = assembly.GetManifestResourceStream(resourceName))
     {
         if (stream == null)
             throw new Exception(string.Format("Resource, named {0}, not found.", resourceName));
         using(var reader = new StreamReader(stream))
             html = reader.ReadToEnd();
     }
     var document = new HtmlDocument();
     document.LoadHtml2(html);
     Document = document;
 }
开发者ID:Sword-Breaker,项目名称:fizzler,代码行数:16,代码来源:SelectorBaseTest.cs

示例7: GetUserInfoAsync

        public async Task<NicoNicoUserEntry> GetUserInfoAsync() {

            try {

                Owner.Status = "ユーザー情報取得中";
                var ret = new NicoNicoUserEntry();

                //ユーザーページのhtmlを取得
                var a = await NicoNicoWrapperMain.Session.GetAsync(UserPage);

                //htmlをロード
                var doc = new HtmlDocument();
                doc.LoadHtml2(a);

                //ユーザープロファイル
                var detail = doc.DocumentNode.SelectSingleNode("//div[@class='userDetail']");
                var profile = detail.SelectSingleNode("child::div[@class='profile']");
                var account = profile.SelectSingleNode("child::div[@class='account']");

                ret.UserIconUrl = detail.SelectSingleNode("child::div[@class='avatar']/img").Attributes["src"].Value;
                ret.UserName = profile.SelectSingleNode("child::h2").InnerText.Trim();
                ret.Id = account.SelectSingleNode("child::p[@class='accountNumber']").InnerText.Trim();

                var temp = profile.SelectSingleNode("child::ul[@class='userDetailComment channel_open_mt0']/li/p/span");

                ret.Description = temp == null ? "" : temp.InnerHtml;

                ret.UserPage = UserPage;

                //html特殊文字をデコード
                ret.Description = HttpUtility.HtmlDecode(ret.Description);

                //URLをハイパーリンク化する エンコードされてると正しく動かない
                ret.Description = HyperLinkReplacer.Replace(ret.Description);

                //&だけエンコード エンコードしないとUIに&が表示されない
                ret.Description = ret.Description.Replace("&", "&amp;");


                Owner.Status = "";
                return ret;
            } catch(RequestTimeout) {

                return null;
            }

        }
开发者ID:mrtska,项目名称:SRNicoNico,代码行数:47,代码来源:NicoNicoUser.cs

示例8: GetFavoriteUser

        public List<NicoNicoFavoriteUser> GetFavoriteUser()
        {
            var url = "http://www.nicovideo.jp/my/fav/user?page=" + Page++;
            var a = NicoNicoWrapperMain.Session.GetAsync(url).Result;

            List<NicoNicoFavoriteUser> ret = new List<NicoNicoFavoriteUser>();

            var doc = new HtmlDocument();
            doc.LoadHtml2(a);

            var content = doc.DocumentNode.SelectSingleNode("//div[@class='content']");

            var outers = content.SelectNodes("child::div[@class='articleBody']/div[@class='outer']");

            //終了
            if(outers == null) {

                return null;
            }

            foreach(var entry in outers) {

                NicoNicoFavoriteUser user = new NicoNicoFavoriteUser();

                user.UserPage = "http://www.nicovideo.jp" + entry.SelectSingleNode("child::div[@class='section']/h5/a").Attributes["href"].Value;
                user.Name = entry.SelectSingleNode("child::div[@class='section']/h5/a").InnerText.Trim();
                user.ThumbnailUrl = entry.SelectSingleNode("child::div[@class='thumbContainer']/a/img").Attributes["src"].Value;

                var p = entry.SelectSingleNode("child::div[@class='section']/p[1]");
                user.Description = p == null ? "" : p.InnerText.Trim();

                //説明がなかったら
                if(user.Description == "ニコレポリストに追加/編集する") {

                    user.Description = "";
                }
                //改行を空白に置換
                user.Description = user.Description.Replace('\n', ' ');
                ret.Add(user);
            }
            return ret;
        }
开发者ID:S--Minecraft,项目名称:SRNicoNico,代码行数:42,代码来源:NicoNicoFavorite.cs

示例9: OnRun

        protected override int OnRun(string[] args)
        {
            if (OutputFormat != NodeOutputFormat.Default
                && OutputFormat != NodeOutputFormat.Full)
                Console.Error.WriteLine("WARNING! The output format option is not yet supported.");

            var arg = ((IEnumerable<string>)args).GetEnumerator();
            
            if (!arg.MoveNext())
                throw new ApplicationException("Missing CSS selector.");

            var selector = arg.Current;

            var document = new HtmlDocument();
            if(!arg.MoveNext() || arg.Current == "-")
                document.LoadHtml2(Console.In.ReadToEnd());
            else
                document.Load2(arg.Current);

            var i = 0;
            foreach (var node in document.DocumentNode.QuerySelectorAll(selector))
            {
                if (i > 0 && Separator.Length > 0) 
                    Console.WriteLine(Separator);
                
                if (LineInfo)
                    Console.Write("@{0},{1}: ", node.Line, node.LinePosition);

                Output(node);
                Console.WriteLine();
                i++;
            }

            //
            // Exit code = 0 (found) or 1 (not found)
            //

            return i > 0 ? 0 : 1;
        }
开发者ID:Sword-Breaker,项目名称:fizzler,代码行数:39,代码来源:SelectCommand.cs

示例10: GetUserInfo

        public NicoNicoUserEntry GetUserInfo()
        {
            Owner.Status = "ユーザー情報取得中";
            var ret = new NicoNicoUserEntry();

            //ユーザーページのhtmlを取得
            var a = NicoNicoWrapperMain.Session.GetAsync(UserPage).Result;

            //htmlをロード
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml2(a);

            //ユーザープロファイル
            HtmlNode detail = doc.DocumentNode.SelectSingleNode("//div[@class='userDetail']");
            HtmlNode profile = detail.SelectSingleNode("child::div[@class='profile']");
            HtmlNode account = profile.SelectSingleNode("child::div[@class='account']");

            ret.UserIconUrl = detail.SelectSingleNode("child::div[@class='avatar']/img").Attributes["src"].Value;
            ret.UserName = profile.SelectSingleNode("child::h2").InnerText.Trim();
            ret.Id = account.SelectSingleNode("child::p[@class='accountNumber']").InnerText.Trim();
            ret.Gender = account.SelectSingleNode("child::p[2]").InnerText.Trim();
            ret.BirthDay = account.SelectSingleNode("child::p[3]").InnerText.Trim();
            ret.Region = account.SelectSingleNode("child::p[4]").InnerText.Trim();

            var temp = profile.SelectSingleNode("child::ul[@class='userDetailComment channel_open_mt0']/li/p/span");

            ret.Description = temp == null ? "" : temp.InnerHtml;

            ret.UserPage = UserPage;

            //URLをハイパーリンク化する
            ret.Description = HyperLinkParser.Parse(ret.Description);

            Owner.Status = "";
            return ret;
        }
开发者ID:S--Minecraft,项目名称:SRNicoNico,代码行数:36,代码来源:NicoNicoUser.cs

示例11: NextNicoRepo

        //過去のニコレポを取得
        public IList<NicoNicoNicoRepoDataEntry> NextNicoRepo()
        {
            //もう過去の二コレポは存在しない
            if(NextUrl == null || NextUrl.Equals("end")) {

                return null;
            }

            //ビヘイビア暴発
            if(PrevUrl == NextUrl) {

                return null;
            }

            //APIと言うのか謎
            var api = PrevUrl = NextUrl;

            //html
            var html = NicoNicoWrapperMain.Session.GetAsync(api).Result;

            IList<NicoNicoNicoRepoDataEntry> data = new List<NicoNicoNicoRepoDataEntry>();

            //XPathでhtmlから抜き出す
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml2(html);

            StoreData(doc, data);

            return data;
        }
开发者ID:mrtska,项目名称:SRNicoNico,代码行数:31,代码来源:NicoNicoNicoRepo.cs

示例12: GetHistroyData

        //たまに失敗するから注意
        public List<NicoNicoHistoryData> GetHistroyData()
        {
            History.Status = "視聴履歴取得中";
            int retry = 1;
            start:
            //たまに失敗する

            HttpResponseMessage result = NicoNicoWrapperMain.Session.GetResponseAsync(HistoryUrl).Result;

            //失敗
            if(result.StatusCode == HttpStatusCode.ServiceUnavailable) {

                History.Status = "視聴履歴取得失敗(" + retry++ + "回)";
                goto start;
            }

            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml2(result.Content.ReadAsStringAsync().Result);

            var info = doc.DocumentNode.SelectNodes(GetVideoInfoXPath);

            List<NicoNicoHistoryData> ret = new List<NicoNicoHistoryData>();

            if(info == null) {

                History.Status = "視聴履歴はありません。";

                return ret;
            }

            foreach(HtmlNode node in info) {

                NicoNicoHistoryData data = new NicoNicoHistoryData();

                //---各種情報取得---
                data.ThumbnailUrl = node.SelectSingleNode("child::div[@class='thumbContainer']/a/img").Attributes["data-original"].Value;

                //削除されていない動画だったら
                if(!data.ThumbnailUrl.Contains("deleted")) {

                    data.Length = node.SelectSingleNode("child::div[@class='thumbContainer']/span").InnerText;
                } else {

                    data.ThumbnailUrl = "http://www.nicovideo.jp/" + data.ThumbnailUrl;
                }
                data.WatchDate = node.SelectSingleNode("child::div[@class='section']/p").ChildNodes["#text"].InnerText;
                data.WatchCount = node.SelectSingleNode("child::div[@class='section']/p/span").InnerText;

                data.Title = HttpUtility.HtmlDecode(node.SelectSingleNode("child::div[@class='section']/h5/a").InnerText);
                data.Id = node.SelectSingleNode("child::div[@class='section']/h5/a").Attributes["href"].Value.Substring(6);

                data.ViewCounter = node.SelectSingleNode("child::div[@class='section']/ul[@class='metadata']/li[@class='play']").InnerText;
                data.CommentCounter = node.SelectSingleNode("child::div[@class='section']/ul[@class='metadata']/li[@class='comment']").InnerText;
                data.MylistCounter = node.SelectSingleNode("child::div[@class='section']/ul[@class='metadata']/li[@class='mylist']/a").InnerText;
                data.PostDate = node.SelectSingleNode("child::div[@class='section']/ul[@class='metadata']/li[@class='posttime']").InnerText;

                ret.Add(data);
            }

            History.Status = "視聴履歴取得完了";

            return ret;
        }
开发者ID:mrtska,项目名称:SRNicoNico,代码行数:64,代码来源:NicoNicoHistory.cs

示例13: ProcessLink

 public override string ProcessLink()
 {
     KeyValuePair<string, string[]> kvpLinks = enrLinks.Current;
     HtmlDocument document = new HtmlDocument();
     document.LoadHtml2(_wc.DownloadStringUsingResponseEncoding(kvpLinks.Value[0]));
     HtmlNode rootNode = document.DocumentNode;
     if (isNew) rootNode = rootNode.QuerySelector("td.ratc");
     ReadOnlyCollection<HtmlNode> nodes = new ReadOnlyCollection<HtmlNode>(rootNode.QuerySelectorAll("tr[id='resultsc'] pre").ToArray());
     string tableTxt, date;
     string[] tableLines, tip, score;
     IvnetValues values;
     Match m;
     foreach (HtmlNode node in nodes)
     {
         tableTxt = node.InnerText;
         tableLines = tableTxt.Split('\n');
         values = new IvnetValues();
         m = _rxHeader.Match(tableLines[0]);
         values.Country = m.Groups["Country"].Value;
         values.League = m.Groups["League"].Value.Trim(" -".ToCharArray());
         values.Round = m.Groups["Round"].Value;
         values.Round = Convert.ToInt32(values.Round) == 0 ? "01" : values.Round;
         for (int i = 1; i < tableLines.Length - 1; i++)
         {
             m = _rx.Match(tableLines[i]);
             date = m.Groups["Date"].Value.Trim();
             if (date != "") values.Date = date;     //DateTime.Parse(date + " " + _thisYear).ToString("yyyy-MM-dd");
             values.HomeTeam = m.Groups["HTeam"].Value.Trim();
             values.AwayTeam = m.Groups["ATeam"].Value.Trim();
             values.ForecastH = m.Groups["FH"].Value;
             values.ForecastD = m.Groups["FD"].Value;
             values.ForecastA = m.Groups["FA"].Value;
             tip = m.Groups["Tip"].Value.Split('-');
             values.TipGoalsH = values.TipGoalsA = null;
             if (tip.Length==2)
             {
                 values.TipGoalsH = tip[0];
                 values.TipGoalsA = tip[1];
             }
             score = m.Groups["Score"].Value.Split('-');
             values.ScoreH = values.ScoreA = null;
             if (score.Length == 2)
             {
                 values.ScoreH = score[0];
                 values.ScoreA = score[1];
             }
             /*
             Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9}-{10} {11}:{12}", values.Country, values.League, values.Round, values.Date,
                 values.HomeTeam, values.AwayTeam, values.ForecastH, values.ForecastD, values.ForecastA, values.TipGoalsH, values.TipGoalsA,
                 values.ScoreH, values.ScoreA);
             */
             if (insert(values) == 0) Console.WriteLine("something is wrong [Ivnet.ProcessLink]");
         }
     }
     return kvpLinks.Key;
 }
开发者ID:TheHalcyonSavant,项目名称:SoccerBase,代码行数:56,代码来源:Ivnet.cs

示例14: GetWatchApiData

        //動画ページを指定
        public static WatchApiData GetWatchApiData(string videoPage)
        {
            //動画ページのhtml取得
            var response = NicoNicoWrapperMain.GetSession().GetResponseAsync(videoPage).Result;

            //チャンネル、公式動画
            if(response.StatusCode == HttpStatusCode.MovedPermanently) {

                response = NicoNicoWrapperMain.GetSession().GetResponseAsync(response.Headers.Location.OriginalString).Result;
            }
            //削除された動画
            if(response.StatusCode == HttpStatusCode.NotFound) {

                return null;
            }
            //混雑中
            if(response.StatusCode == HttpStatusCode.ServiceUnavailable) {

                return null;
            }

            string html = response.Content.ReadAsStringAsync().Result;

            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml2(html);

            //htmlからAPIデータだけを綺麗に抜き出す すごい
            var container = doc.DocumentNode.QuerySelector("#watchAPIDataContainer");

            if(container == null) {

                return null;
            }

            var data = container.InnerHtml;

            //html特殊文字をデコードする
            data = HttpUtility.HtmlDecode(data);

            //jsonとしてAPIデータを展開していく
            var json = DynamicJson.Parse(data);

            //GetFlvの結果
             string flv = json.flashvars.flvInfo;

            //2重にエンコードされてるので二回
            flv = HttpUtility.UrlDecode(flv);
            flv = HttpUtility.UrlDecode(flv);

            WatchApiData ret = new WatchApiData();

            //&で繋がれているので剥がす
            var getFlv = flv.Split(new char[] { '&' }).ToDictionary(source => source.Substring(0, source.IndexOf('=')),
            source => Uri.UnescapeDataString(source.Substring(source.IndexOf('=') + 1)));

            ret.GetFlv = new NicoNicoGetFlvData(getFlv);

            //動画情報
            var videoDetail = json.videoDetail;

            //---情報を詰める---
            ret.Cmsid = videoDetail.id;
            ret.MovieType = json.flashvars.movie_type;
            ret.Title = HttpUtility.HtmlDecode(videoDetail.title);  //html特殊文字をデコード
            ret.Thumbnail = videoDetail.thumbnail;
            ret.Description = videoDetail.description;
            ret.PostedAt = videoDetail.postedAt;
            ret.Length = (int) videoDetail.length;
            ret.ViewCounter = (int) videoDetail.viewCount;
            ret.CommentCounter = (int) videoDetail.commentCount;
            ret.MylistCounter = (int) videoDetail.mylistCount;
            ret.YesterdayRank = videoDetail.yesterday_rank == null ? "圏外" : videoDetail.yesterday_rank + "位";
            ret.HighestRank = videoDetail.highest_rank == null ? "圏外" : videoDetail.highest_rank + "位";
            ret.Token = json.flashvars.csrfToken;

            if(json.uploaderInfo()) {

                //投稿者情報
                var uploaderInfo = json.uploaderInfo;

                ret.UploaderId = uploaderInfo.id;
                ret.UploaderIconUrl = uploaderInfo.icon_url;
                ret.UploaderName = uploaderInfo.nickname;
                ret.UploaderIsFavorited = uploaderInfo.is_favorited;

            } else if(json.channelInfo()) {

                //投稿者情報
                var channelInfo = json.channelInfo;

                ret.UploaderId = channelInfo.id;
                ret.UploaderIconUrl = channelInfo.icon_url;
                ret.UploaderName = channelInfo.name;
                ret.UploaderIsFavorited = channelInfo.is_favorited == 1 ? true : false;

                ret.IsChannelVideo = true;
            }

            ret.Description = HyperLinkParser.Parse(ret.Description);
//.........这里部分代码省略.........
开发者ID:S--Minecraft,项目名称:SRNicoNico,代码行数:101,代码来源:NicoNicoWatchApi.cs

示例15: ProcessLink

        public override string ProcessLink()
        {
            KeyValuePair<string, string[]> kvpLinks = enrLinks.Current;
            string link = kvpLinks.Value[0], blockHeaderBegin = kvpLinks.Value[1], blockHeaderEnd = kvpLinks.Value[2];
            string webTxt = _wc.DownloadStringUsingResponseEncoding(link);
            string strBegin = "name=\"Fixtures\"><![CDATA[", strEnd = "]]></c></n></n></n></n></n>";
            int startIdx = webTxt.IndexOf(strBegin) + strBegin.Length, endIdx = webTxt.IndexOf(strEnd, startIdx);
            if (blockHeaderBegin.Length > 0)
            {
                blockHeaderBegin = "<h2 class=\"title\">" + blockHeaderBegin + "</h2>";
                startIdx = webTxt.IndexOf(blockHeaderBegin, startIdx) + blockHeaderBegin.Length;
            }
            if (blockHeaderEnd.Length > 0)
            {
                int endIdx2 = webTxt.IndexOf("<h2 class=\"title\">" + blockHeaderEnd + "</h2>", startIdx, endIdx - startIdx);
                if (endIdx2 > -1) endIdx = endIdx2;
            }
            string html = webTxt.Substring(startIdx, endIdx - startIdx);
            //System.IO.File.WriteAllText("debugDoc.xml", html);

            HtmlDocument document = new HtmlDocument();
            document.LoadHtml2(webTxt);
            //document.Save("debugDoc.xml");
            Match m = _rx.Match(document.DocumentNode.QuerySelector("page").Attributes["title"].Value);
            SportRadarValues values = new SportRadarValues();
            values.Country = m.Groups["Country"].Value.Trim();
            values.League = m.Groups["League"].Value.Trim();
            values.Season = m.Groups["Season"].Value.Trim();

            document.LoadHtml2(html);
            List<HtmlNode> tables = new List<HtmlNode>(document.DocumentNode.QuerySelectorAll("table.normaltable").ToArray());
            List<HtmlNode> headerRounds = new List<HtmlNode>(document.DocumentNode.QuerySelectorAll("h2.title").ToArray());
            List<HtmlNode> tableRows;
            List<HtmlNode> tableCells;
            int Round = 0;
            string homeScore, awayScore, strRound = "";
            foreach (HtmlNode table in tables)
            {
                tableRows = new List<HtmlNode>(table.QuerySelectorAll("tbody tr").ToArray());
                if (Table == "archive")
                {
                    strRound = headerRounds[++Round-1].InnerText.Trim();
                    strRound = strRound.IndexOf("Round") > -1 ? strRound.Substring(6) : Round.ToString();
                }
                foreach (HtmlNode row in tableRows)
                {
                    tableCells = new List<HtmlNode>(row.QuerySelectorAll("td").ToArray());
                    values.Date = DateTime.Parse(tableCells[0].InnerText.Trim().Split(' ')[0]).ToString("yyyy-MM-dd");
                    values.HomeTeam = tableCells[1].QuerySelector("span.home").InnerText.Trim();
                    values.AwayTeam = tableCells[1].QuerySelector("span.away").InnerText.Trim();
                    values.HomeOdds = tableCells[2].InnerText.Trim();
                    values.DrawOdds = tableCells[3].InnerText.Trim();
                    values.AwayOdds = tableCells[4].InnerText.Trim();
                    m = _rxScore.Match(tableCells[6].InnerText.Trim());
                    homeScore = m.Groups["HScore"].Value;
                    awayScore = m.Groups["AScore"].Value;
                    values.ScoreH = values.ScoreA = null;
                    if (homeScore != "" && awayScore != "")
                    {
                        values.ScoreH = homeScore;
                        values.ScoreA = awayScore;
                    }
                    values.Round = Table == "archive" ? strRound : Round.ToString();
                    /*
                    Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10}:{11}",
                        values.Country, values.League, values.Season, values.Round, values.Date, values.HomeTeam, values.AwayTeam,
                        values.HomeOdds, values.DrawOdds, values.AwayOdds, values.ScoreH, values.ScoreA);
                    */
                    if (insert(values) == 0) Console.WriteLine("something is wrong");
                }
            }
            return kvpLinks.Key;
        }
开发者ID:TheHalcyonSavant,项目名称:SoccerBase,代码行数:73,代码来源:SportRadar.cs


注:本文中的HtmlAgilityPack.HtmlDocument.LoadHtml2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。