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


C# CQ.Select方法代码示例

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


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

示例1: Render

        public void Render(CQ html, IYateDataContext dataContext)
        {
            var selector = _selector.GetValue(dataContext).ToString();
            var patterns = html.Select(selector);

            var patternHtml = CQ.CreateFragment(patterns.First());

            dataContext.PatternContainer.Add(
                _name.GetValue(dataContext).ToString(),
                new YatePattern(patternHtml, AtRules, RuleSets));

            html.Select(selector).Remove();
        }
开发者ID:jakeranderson,项目名称:Yate,代码行数:13,代码来源:PatternAtRule.cs

示例2: BuildBundleData

        public void BuildBundleData(ContentFragmentPageControl contentFragmentPage, CQ parsedContent)
        {
            if (Configuration.OptomizeGlobalCss)
            {
                //Get the themes CSS files
                CQ elements = parsedContent.Select(BuildSelector);

                foreach (IDomObject element in elements)
                {
                    string mediaType = element.GetAttribute("media") ?? "screen";

                    if (mediaType.IndexOf("screen", StringComparison.OrdinalIgnoreCase) > -1)
                    {
                        string src = element.GetAttribute("href");

                        if (!string.IsNullOrEmpty(src) && mediaType.IndexOf("dynamic-style.aspx", StringComparison.OrdinalIgnoreCase) < 0 && src.EndsWith(".css"))
                        {
                            IBundledFile file = _bundledFileFactory.GetBundleFile("css", src, contentFragmentPage, "");

                            if (file != null)
                            {
                                HandleLayoutCssPath(file);
                                
                                Include(file);
                            }
                        }
                    }
                }


            }
        }
开发者ID:4-Roads,项目名称:FourRoads.TelligentCommunity,代码行数:32,代码来源:StandardStyleBundle.cs

示例3: Render

 public void Render(CQ dom)
 {
     foreach (var selector in _renderingParameters.Selectors)
     {
         ////todo: figure out prepend and such
         //if (renderingParameters.Expressions.Count() > 1)
         //{
         //    var method = renderingParameters.Expressions[1].ToLower();
         //    if (method == "append")
         //    {
         //        dom.Select(selector).Text(dom.Select(selector).Text() + renderingParameters.Expressions.FirstOrDefault());
         //    }
         //    else if (method == "prepend")
         //    {
         //        dom.Select(selector).Text(renderingParameters.Expressions.FirstOrDefault() + dom.Select(selector).Text());
         //    }
         //    else
         //    {
         //        dom.Select(selector).Text(renderingParameters.Expressions.FirstOrDefault());
         //    }
         //}
         //else
         //{
         dom.Select(selector).Text(_renderingParameters.Expressions.FirstOrDefault());
         //}
     }
 }
开发者ID:jakeranderson,项目名称:Yate,代码行数:27,代码来源:TextRenderingRule.cs

示例4: Render

        public void Render(CQ dom, string selector, IYateDataContext dataContext)
        {
            string format;

            if (_format != null)
            {
                format = _format.GetValue(dataContext).ToString();
            }
            else
            {
                format = dom.Select(selector).Text();
            }

            dom.Select(selector).Text(
                string.Format(format, _text.GetValue(dataContext)));
        }
开发者ID:jakeranderson,项目名称:Yate,代码行数:16,代码来源:FormatTextProperty.cs

示例5: ParseCommandsNames

 static string[] ParseCommandsNames(CQ dom, IDomObject @event)
 {
     var commands =
         dom.Select(
             "td.today-name > span.command > div.today-member-name, td.name > span.command div.member-name",
             @event).Map(node => node.Cq().Text().Trim().Replace(Nbsp, ' ')).ToArray();
     Debug.Assert(commands.Count() == 2, "Teams names have not been recognized: " + @event.InnerHTML);
     return commands;
 }
开发者ID:oreshkor,项目名称:luckybird,代码行数:9,代码来源:SoccerPageParser.cs

示例6: ParseEventDate

        static DateTimeOffset ParseEventDate(CQ dom, IDomObject @event)
        {
            var date = dom.Select("td.date", @event).Text().Trim();

            DateTimeOffset eventDate;
            DateTimeOffset.TryParse(date, out eventDate);

            return eventDate;
        }
开发者ID:oreshkor,项目名称:luckybird,代码行数:9,代码来源:SoccerPageParser.cs

示例7: ParseEvents

 static IEnumerable<ParsedEventData> ParseEvents(CQ dom, IDomObject @event)
 {
     return dom.Select("td.js-price", @event)
               .Map(node =>
                        {
                            var domNode = node.Cq();
                            var coefficient = double.Parse(domNode.Find("span.selection-link").Text().Trim());
                            var specification = domNode.Children().Remove().End().Text().Trim();
                            return new ParsedEventData {Coefficient = coefficient, Specification = specification};
                        });
 }
开发者ID:oreshkor,项目名称:luckybird,代码行数:11,代码来源:SoccerPageParser.cs

示例8: ParseLines

        static IEnumerable<EventLine> ParseLines(CQ dom, IEnumerable<string> eventNames)
        {
            var events = dom.Select("table.foot-market tr.event-header");

            foreach (var @event in events)
            {
                var commands = ParseCommandsNames(dom, @event);

                var eventDate = ParseEventDate(dom, @event);

                var eventsData = ParseEvents(dom, @event).ToList();

                yield return
                    new EventLine(string.Join("-", commands), eventDate, CreateBets(eventNames, eventsData).ToArray());
            }
        }
开发者ID:oreshkor,项目名称:luckybird,代码行数:16,代码来源:SoccerPageParser.cs

示例9: HTMLEnderecoParse

        public HTMLEnderecoParse(WebRequest requisicao, int cep)
        {
            var bytes = System.Text.Encoding.ASCII.GetBytes(string.Format("cepEntrada={0}&tipoCep=&cepTemp&metodo=buscarCep", cep));
            requisicao.ContentLength = bytes.Length;
            using (var os = requisicao.GetRequestStream())
            {
                os.Write(bytes, 0, bytes.Length);
                os.Close();
            }

            var resposta = requisicao.GetResponse();
            using (var responseStream = resposta.GetResponseStream())
            using (var reader = new StreamReader(responseStream))
            {
                var html = reader.ReadToEnd();
                _csQueryParsed = CQ.Create(html);
            }

            if (EhValido)
            {
                var htmlResp = _csQueryParsed.Select(".respostadestaque");
                Endereco = new Endereco
                {
                    Bairro = htmlResp.Eq(1).Contents().ToHtmlString().Trim()
                    ,
                    Cep = htmlResp.Eq(3).Contents().ToHtmlString().Trim()
                    ,
                    Cidade = htmlResp.Eq(2).Contents().ToHtmlString().Trim().Split('/')[0].Trim()
                    ,
                    Estado = htmlResp.Eq(2).Contents().ToHtmlString().Trim().Split('/')[1].Trim()
                    ,
                    TipoDeLogradouro = htmlResp.Eq(0).Contents().ToHtmlString().Trim().Split(' ')[0]
                };
                var logradouro = htmlResp.Eq(0).Contents().ToHtmlString().Trim().Split(' ');
                var logradouroCompleto = string.Empty;
                for (var i = 0; i < logradouro.Length; i++)
                {
                    if (i <= 0) continue;
                    if (logradouro[i] == "-") break;
                    logradouroCompleto += logradouro[i];
                    logradouroCompleto += " ";
                }
                Endereco.Logradouro = logradouroCompleto.Trim();
            }
        }
开发者ID:Ridermansb,项目名称:CorreiosRESTfulAPI,代码行数:45,代码来源:EnderecoParse.cs

示例10: 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

示例11: CheckChildren

        public void CheckChildren(string parentUrl, string childSelector, string html)
        {
            var dom = new CQ(html);
            var links = dom.Select(childSelector);
            var childrenChecked = 0;

            Parallel.ForEach(links, new ParallelOptions() { MaxDegreeOfParallelism = Config.MaxChildThreads }, o =>
            {
                childrenChecked++;
                var url = o.Attributes["href"];
                // ignore empty
                if (String.IsNullOrWhiteSpace(url))
                    return;
                // ignore javascript
                if (url.ToLower().StartsWith("javascript:"))
                    return;

                // jump out if url should be ignored
                if (Config.IgnoreUrlsStartingWith.Any(ignore => url.StartsWith(ignore)))
                    return;

                // check for relative url
                if (!url.StartsWith("http://") &&
                    !url.StartsWith("https://") &&
                    !url.StartsWith("//"))
                {
                    if (url.StartsWith("/"))
                        url = new Uri(parentUrl).GetLeftPart(UriPartial.Authority) + url;

                    else
                        url = parentUrl + url;
                }

                // check for protocol relative url
                if (url.StartsWith("//"))
                {
                    url = new Uri(parentUrl).GetLeftPart(UriPartial.Scheme) + url.Substring(2);
                }

                PerformCheck(url, null, true);
            });

            Console.WriteLine("Checked {0} children of {1}", childrenChecked, parentUrl);
        }
开发者ID:stuartfaz,项目名称:ubiquitous-octo-potato,代码行数:44,代码来源:Checker.cs

示例12: ProcessDisplayElement

        public void ProcessDisplayElement(CQ parsedContent)
        {
            CQ elements = parsedContent.Select(ReplaceSelector);
            bool foundFirstScript = false;

            ////WE can minify the inline javascript, however this costs more than the time it saves from the bytes saved not sent over the network
            foreach (IDomObject element in elements)
            {
                string path = element.GetAttribute("src") ?? string.Empty;

                if (!path.EndsWith(BundlePath))
                {
                    if (PartOfBundle(path))
                    {
                        foundFirstScript = UpdateJavascriptPath(foundFirstScript, element);
                    }
                }
            }
        }
开发者ID:4-Roads,项目名称:FourRoads.TelligentCommunity,代码行数:19,代码来源:StandardScriptBundle.cs

示例13: Sort

        public string Sort()
        {
            if (string.IsNullOrWhiteSpace(_content))
                return string.Empty;

            var dom = new CQ(_content);
            var root = dom.Select("Project");

            foreach (var element in root.Children())
            {
                if (element.RequiresSort())
                {
                    element.SortChildren();
                }

            }

            return dom.Render();
        }
开发者ID:robcthegeek,项目名称:CsProjSorter,代码行数:19,代码来源:ProjectFileSorter.cs

示例14: Render

        public void Render(CQ html, string selector, IYateDataContext dataContext)
        {
            var domObjects = html.Select(selector);
            var pattern = dataContext.PatternContainer[_patternName.GetValue(dataContext).ToString()];
            var model = _model.GetValue(dataContext);

            if (model is ICollection)
            {
                var enumModels = model as ICollection;

                foreach (var enumModel in enumModels)
                {
                    RunPattern(dataContext, enumModel, domObjects, pattern);
                }
            }
            else
            {
                RunPattern(dataContext, model, domObjects, pattern);
            }
        }
开发者ID:jakeranderson,项目名称:Yate,代码行数:20,代码来源:ApplyPatternProperty.cs

示例15: Process

        public void Process(CQ parsedContent)
        {
            if (_microDataEntries != null)
            {
                try
                {
                    var body = parsedContent.Select("body");
                    Dictionary<Guid, IContent> contentLookup = new Dictionary<Guid, IContent>();

                    foreach (MicroDataEntry semanticEntry in _microDataEntries)
                    {
                        Guid semanticType = semanticEntry.ContentType.GetValueOrDefault(Guid.Empty);

                        if (semanticType == Guid.Empty)
                        {
                            ProcessSymanticEntry(semanticEntry, body);
                        }
                        else if (WebContextualContentTypes.ContainsKey(semanticType))
                        {
                            if (!contentLookup.ContainsKey(semanticType))
                            {
                                contentLookup.Add(semanticType, WebContextualContentTypes[semanticType].GetCurrentContent(new WebContext()));
                            }

                            if (contentLookup[semanticType] != null)
                            {
                                ProcessSymanticEntry(semanticEntry, body);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    new Telligent.Evolution.Components.CSException(Telligent.Evolution.Components.CSExceptionType.UnknownError, "MicroDataPlugin unkonw error", ex).Log();
                }
            }
        }
开发者ID:4-Roads,项目名称:FourRoads.TelligentCommunity,代码行数:37,代码来源:MicroDataProcessor.cs


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