コード例 #1
0
        public HtmlExtractor Seek(IElementPredicate predicate)
        {
            lastMatch = null;

            SeekWithin(predicate, null);
            return this;
        }
コード例 #2
0
        public HtmlExtractor Seek(IElementPredicate predicate)
        {
            lastMatch = null;

            SeekWithin(predicate, null);
            return(this);
        }
コード例 #3
0
        /// <summary>
        /// Does not do tag balancing.
        /// </summary>
        public string CollectHtmlUntilPredicate(IElementPredicate elementp)
        {
            StringBuilder result = new StringBuilder();
            Element       el;

            while (null != (el = Next()))
            {
                if (elementp.IsMatch(el))
                {
                    break;
                }
                result.Append(html, el.Offset, el.Length);
            }
            return(result.ToString());
        }
コード例 #4
0
        public HtmlExtractor MatchNext(IElementPredicate predicate, bool ignoreWhitespace)
        {
            lastMatch = null;

            Element e;

            do
            {
                e = parser.Next();
            }while (e != null && ignoreWhitespace && IsWhitespaceOrZeroLengthText(e));

            if (e != null && predicate.IsMatch(e))
            {
                lastMatch = e;
            }

            return(this);
        }
コード例 #5
0
        public HtmlExtractor SeekWithin(IElementPredicate predicate, IElementPredicate withinPredicate)
        {
            lastMatch = null;

            Element e;

            while (null != (e = parser.Next()))
            {
                if (predicate.IsMatch(e))
                {
                    lastMatch = e;
                    break;
                }
                if (withinPredicate != null && withinPredicate.IsMatch(e))
                {
                    break;
                }
            }

            return(this);
        }
コード例 #6
0
 public SmartPredicate(string criterion)
 {
     actualPredicate = HtmlExtractor.Parse(criterion);
 }
コード例 #7
0
 public PredicatePair(IElementPredicate match, IElementPredicate stop)
 {
     _match = match;
     _stop  = stop;
 }
コード例 #8
0
 /// <summary>
 /// Does not do tag balancing.
 /// </summary>
 public string CollectTextUntilPredicate(IElementPredicate elementp)
 {
     return(HtmlUtils.HTMLToPlainText(CollectHtmlUntilPredicate(elementp)));
 }
コード例 #9
0
        public HtmlExtractor SeekWithin(IElementPredicate predicate, IElementPredicate withinPredicate)
        {
            lastMatch = null;

            Element e;
            while (null != (e = parser.Next()))
            {
                if (predicate.IsMatch(e))
                {
                    lastMatch = e;
                    break;
                }
                if (withinPredicate != null && withinPredicate.IsMatch(e))
                    break;
            }

            return this;
        }
コード例 #10
0
 public SmartPredicate(string criterion)
 {
     actualPredicate = HtmlExtractor.Parse(criterion);
 }
コード例 #11
0
 public PredicatePair(IElementPredicate match, IElementPredicate stop)
 {
     _match = match;
     _stop = stop;
 }
コード例 #12
0
 /// <summary>
 /// Does not do tag balancing.
 /// </summary>
 public string CollectHtmlUntilPredicate(IElementPredicate elementp)
 {
     StringBuilder result = new StringBuilder();
     Element el;
     while (null != (el = Next()))
     {
         if (elementp.IsMatch(el))
             break;
         result.Append(html, el.Offset, el.Length);
     }
     return result.ToString();
 }
コード例 #13
0
 /// <summary>
 /// Does not do tag balancing.
 /// </summary>
 public string CollectTextUntilPredicate(IElementPredicate elementp)
 {
     return HtmlUtils.HTMLToPlainText(CollectHtmlUntilPredicate(elementp));
 }
コード例 #14
0
        public HtmlExtractor MatchNext(IElementPredicate predicate, bool ignoreWhitespace)
        {
            lastMatch = null;

            Element e;
            do
            {
                e = parser.Next();
            }
            while (e != null && ignoreWhitespace && IsWhitespaceOrZeroLengthText(e));

            if (e != null && predicate.IsMatch(e))
                lastMatch = e;

            return this;
        }