Example #1
0
        public IList <IHtmlElement> SelectorAll(string html, string path, HtmlSelectorPathType pathType = HtmlSelectorPathType.XPath)
        {
            var dom = _htmlParser.Parse(html);

            if (pathType == HtmlSelectorPathType.Css)
            {
                var node = dom.QuerySelectorAll(path);

                return(Convent(node));
            }
            else
            {
                throw new NotSupportedException($"不支持{pathType}的解析方式");
            }
        }
Example #2
0
        public IList <IHtmlElement> SelectorAll(string html, string path, HtmlSelectorPathType pathType = HtmlSelectorPathType.XPath)
        {
            HtmlDocument htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(html);

            if (pathType == HtmlSelectorPathType.XPath)
            {
                var node = htmlDocument.DocumentNode.SelectNodes(path);

                return(Convent(node));
            }
            else if (pathType == HtmlSelectorPathType.Css)
            {
                var node = htmlDocument.DocumentNode.QuerySelectorAll(path);

                return(Convent(node));
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Example #3
0
 public IList <IHtmlElement> SelectorAll(string path, HtmlSelectorPathType pathType = HtmlSelectorPathType.XPath)
 {
     return(_htmlQuery.SelectorAll(_html, path, pathType));
 }
Example #4
0
 public IHtmlElement Selector(string path, HtmlSelectorPathType pathType = HtmlSelectorPathType.XPath)
 {
     return(_htmlQuery.Selector(_html, path, pathType));
 }
Example #5
0
 public abstract IList <IHtmlElement> SelectorAll(string path, HtmlSelectorPathType pathType = HtmlSelectorPathType.XPath);
Example #6
0
 public abstract IHtmlElement Selector(string path, HtmlSelectorPathType pathType            = HtmlSelectorPathType.XPath);
Example #7
0
 public SelectorAttribute(string path, HtmlSelectorPathType pathType) : this(path)
 {
     this.PathType = pathType;
 }