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


C# CQ.Find方法代码示例

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


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

示例1: Parse

        public static ScheduleItem Parse(CQ element)
        {
            var speaker = element.Find(".before_hour_text").Text();
            string speakerUrl = !string.IsNullOrWhiteSpace(speaker) ? element.Find(".event_header").Attr("href") : null;
            string title = element.Find(".event_header").Text();

            string startTimeText = element.Find(".top_hour span").First().Text();
            string endTimeText = element.Find(".bottom_hour span").First().Text();

            var startTime = TimeSpan.ParseExact(startTimeText, "g", CultureInfo.InvariantCulture);
            var endTime = TimeSpan.ParseExact(endTimeText, "g", CultureInfo.InvariantCulture);

            return new ScheduleItem(title, speaker, speakerUrl, startTime, endTime);
        }
开发者ID:sebnilsson,项目名称:DevSumScheduler,代码行数:14,代码来源:ScheduleItem.cs

示例2: FromTable

        private static IEnumerable<ScheduleItem> FromTable(CQ tableElement)
        {
            var itemElements = tableElement.Find("tbody tr .event .event_container");

            for (int i = 0; i < itemElements.Length; i++)
            {
                var item = itemElements.Eq(i);

                yield return ScheduleItem.Parse(item);
            }
        }
开发者ID:sebnilsson,项目名称:DevSumScheduler,代码行数:11,代码来源:ScheduleRow.cs

示例3: CustomXhtmlString

    public static IHtmlString CustomXhtmlString(this HtmlHelper helper, XhtmlString value)
    {
      var htmlString = helper.XhtmlString(value).ToHtmlString();
      
      var headline = LocalizationService.Current
        .GetString("/views/common/linklist/headline");
      
      var cq = new CQ(htmlString, HtmlParsingMode.Document);
      cq.Find("ul.link-list").Each(list =>
        {
          var box = CQ.CreateFragment(
            "<div class=\"link-list\">" 
            + "<h4><span class=\"glyphicon glyphicon-link\"></span> " 
            + headline
            + "</h4></div>");
          list.RemoveClass("link-list");
          box.Append(list.OuterHTML);
          list.Cq().ReplaceWith(box);
        });

      return new MvcHtmlString(cq.Find("body").Html());
    }
开发者ID:role7504,项目名称:episerver_book_code_examples,代码行数:22,代码来源:FormattingExtensions.cs

示例4: GetInputFields

        public static Dictionary<string, string> GetInputFields(CQ dom)
        {
            Dictionary<string, string> result = new Dictionary<string, string>();
            foreach (var v in dom.Find("input"))
            {
                var value = v.Cq().Attr("value");
                var key = v.Cq().Attr("name");
                if (!string.IsNullOrWhiteSpace(value) && !string.IsNullOrWhiteSpace(key))
                {
                    if (!result.ContainsKey(key))
                    {
                        result.Add(key, value);
                    }
                    else
                    {
                        result[key] = value;
                    }
                }
            }

            // Get all selects
            foreach (var s in dom.Select("select"))
            {
                var select = s.Cq();
                var key = select.Attr("name");
                foreach (var option in select.Children("option"))
                {
                    var opt = option.Cq();
                    if (!string.IsNullOrWhiteSpace(opt.Attr("selected")))
                    {
                        if (!result.ContainsKey(key))
                        {
                            result.Add(key, opt.Val());
                        }
                        else
                        {
                            result[key] = opt.Val();
                        }
                    }
                }
            }

            return result;
        }
开发者ID:KRSogaard,项目名称:UkData.Scraper,代码行数:44,代码来源:AspScrapingTools.cs

示例5: Volume

        /// <summary>
        /// Parses volume information based on its title element.
        /// </summary>
        /// <param name="hEl"></param>
        public Volume(CQ ul)
        {
            ul.Find("li").Each((el) =>
            {
                var link = new CQ(el).Find("a").First();
                if (link.Count() == 0) return;

                var name = Regex.Replace(link.Attr("href"), "^.+title=", "");

                if (name.Contains("Illustrations") && _illustrationsPage == null)
                {
                    _illustrationsPage = new IllustrationsPage(name);
                }
                else
                {
                    _chapters.Add(new Chapter(name, link.Text()));
                }
            });
        }
开发者ID:EusthEnoptEron,项目名称:BakaPrince,代码行数:23,代码来源:Volume.cs

示例6: ParseLink

 private static ParsedRSSFeedLink ParseLink(IDomObject linkNode)
 {
     ParsedRSSFeedLink parsedRSSFeedLink;
     CQ linkCq = new CQ(linkNode.Clone());
     CQ aCq = linkCq.Find("a");
     if (aCq.Any())
     {
         ParsedRSSFeedLink parsedRSSFeedLink1 = new ParsedRSSFeedLink
         {
             LinkURL = aCq.Attr<string>("href"),
             LinkTitle = aCq.First().Text()
         };
         ParsedRSSFeedLink link = parsedRSSFeedLink1;
         aCq.FirstElement().Remove();
         link.Description = linkCq.Text().Trim();
         parsedRSSFeedLink = link;
     }
     else
     {
         parsedRSSFeedLink = null;
     }
     return parsedRSSFeedLink;
 }
开发者ID:Arithmomaniac,项目名称:PodcastGenerator,代码行数:23,代码来源:JoelRichFeedParser.cs

示例7: PrepareHtml

        private string PrepareHtml(string html)
        {
            // Make title
            if (!Notitle)
            {
                html = "<h2>" + Title + "</h2>" + html;
            }
             html = "<span class=\"invisible chapterstart\">" + (Noheader ? "" : Title) + "</span>" + html;

            // Make sure page break is set
            if (Pagebreak)
            {
                html = "<span class=\"invisible pagebreak\"></span>" + html;
            }

            CQ dom = CQ.CreateFragment("<div class=\"content\">" + html + "</div>");

            // Remove next/prev table
            dom.Find("table:contains('Forward'):contains('Back')").Last().Remove();

            // Find images
            foreach(IDomElement aNode in dom.Find("a.image")) {
                var a = new CQ(aNode);
                var img = new CQ(a.Find("img"));

                var src = img.Attr("src").Replace("/thumb", "");
                src = Regex.Replace(src, @"[.](jpg|png|gif)\/.+$", @".$1", RegexOptions.IgnoreCase);

                var image = new Image(src, new Uri(Wiki)) {Sashie = true};

                CQ node = a.Closest(".thumb").Add(a).First();

                if (_images.Count == 0 && EntryPicture)
                {
                    // We can view it as a full-fledged image since we don't need to worry about text-flow
                    image.Sashie = false;
                    dom.Before(image.Html);
                }
                else
                {
                    node.Before(image.Html);
                    //node.After("<span class=\"image-stopper\"></span>");
                }

                node.Remove();

                _images.Add(image);
            }

            // Catch references
            foreach (IDomElement supNode in dom.Find("sup.reference"))
            {
                var sup = new CQ(supNode);
                CQ footnote = "<span class=\"fn\"></span>";
                CQ oldFootnote = dom.Find("#" + sup.Attr("id").Replace("_ref-", "_note-"));

                footnote.Html(oldFootnote.Find(".reference-text").Html());

                oldFootnote.Remove();
                sup.Before(footnote).Remove();
            }
            // Remove possible reference title
            dom.Find(".references").Prev(":header").Remove();

            // Remove edit links
            dom.Find(".editsection, #toc").Remove();

            // Make smart quotes
            dom.Find("p:contains('\"'), p:contains(\"'\"), li:contains('\"'), li:contains(\"'\")").Each((el) =>
            {
                CQ p = new CQ(el);
                string pHtml = p.Html();

                // Replace quotes
                if (Regex.Matches(pHtml, "&quot;").Count % 2 == 0)
                {

                    pHtml = Regex.Replace(pHtml, "&quot;(.+?)&quot;", "“$1”");
                }
                else
                {
                    Console.WriteLine("NOTICE: possible quotes problem ({0})", pHtml.Trim());
                }

                // Replace single quotes (\b doesn't work)
                pHtml = Regex.Replace(pHtml, "(?<!\\w)'(.+?)'(?!\\w)", "‘$1’");
                // Replace apostrophes
                pHtml = Regex.Replace(pHtml, "'", "’");

                p.Html(pHtml);
            });

            // Parse Ruby
            dom.Find("span > span > span").Each(el =>
            {
                var rubySpan = new CQ(el);
                if(rubySpan.Css("position") == "relative" && rubySpan.Css("left") == "-50%") {
                    var textSpan = rubySpan.Parent().Siblings("span");
                    var containerSpan = textSpan.Parent();
                    if (textSpan.Length == 1 && containerSpan.Css("white-space") == "nowrap")
//.........这里部分代码省略.........
开发者ID:EusthEnoptEron,项目名称:BakaPrince,代码行数:101,代码来源:Page.cs

示例8: DetermineIfMessageIsCloseVoteRequest

        private bool DetermineIfMessageIsCloseVoteRequest(CQ messageContentsNode)
        {
            //message contains "cv-pls", "cv-plz", or "close", and has a link

            var triggerPhrases = new[]
            {
                "cv-pls",
                "cv-plz",
                "close"
            };

            var text = messageContentsNode.Text();

            var hasTriggerPhrase = triggerPhrases
                .Select(x => text.Contains(x))
                .Any(x => x);

            var hasLink = messageContentsNode.Find("a").Any();

            return hasTriggerPhrase && hasLink;
        }
开发者ID:SO-Close-Vote-Reviewers,项目名称:socvr-slack-statbot,代码行数:21,代码来源:ChatScraper.cs

示例9: GetScheduleTableDays

        private static IEnumerable<ScheduleTableDay> GetScheduleTableDays(CQ pageQuery)
        {
            var titleElement = pageQuery.Find("h1");

            var tableElement = pageQuery.Find("#all-events table.tt_timetable");

            yield return new ScheduleTableDay { TitleElement = titleElement, TableElement = tableElement };
        }
开发者ID:sebnilsson,项目名称:DevSumScheduler,代码行数:8,代码来源:ScheduleTable.cs

示例10: GetHeaders

        private static IEnumerable<string> GetHeaders(CQ tableElement)
        {
            var headers = tableElement.Find("thead tr th").Skip(1).ToList();

            var headerTexts = headers.Select(x => (x.InnerText ?? string.Empty).Trim());
            return headerTexts;
        }
开发者ID:sebnilsson,项目名称:DevSumScheduler,代码行数:7,代码来源:ScheduleTable.cs

示例11: ParseBlockTitle

 static string ParseBlockTitle(CQ head)
 {
     return head.Find("div.block-events-head").Children().Remove().End().Text().Trim();
 }
开发者ID:oreshkor,项目名称:luckybird,代码行数:4,代码来源:SoccerPageParser.cs


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