protected override Tag CreateTag(TagData tagData, Tag tag, string url)
        {
            string baseUrl         = tag["HREF"];
            string absoluteBaseUrl = "";

            if (baseUrl != null && baseUrl.Length > 0)
            {
                absoluteBaseUrl   = LinkProcessor.RemoveLastSlash(baseUrl.Trim());
                processor.BaseUrl = absoluteBaseUrl;
            }
            return(new BaseHrefTag(tagData, absoluteBaseUrl));
        }
        /// <summary> Opens a connection based on a given string.
        /// The string is either a file, in which case <code>file://localhost</code>
        /// is prepended to a canonical path derived from the string, or a url that
        /// begins with one of the known protocol strings, i.e. <code>http://</code>.
        /// Embedded spaces are silently converted to %20 sequences.
        /// </summary>
        /// <param name="resource">The name of a file or a url.
        /// </param>
        /// <param name="feedback">The object to use for messages or <code>null</code> for no feedback.
        /// </param>
        /// <exception cref=""> ParserException if the string is not a valid url or file.
        ///
        /// </exception>
        public static WebRequest OpenConnection(string resource, ParserFeedback feedback)
        {
            System.Uri url;
            WebRequest ret;

            try
            {
                url = SupportClass.CreateUri(LinkProcessor.FixSpaces(resource));
                ret = ParserHelper.OpenConnection(url, feedback);
            }
            catch (System.UriFormatException ufe)
            {
                string          msg = "HTMLParser.OpenConnection() : Error in opening a connection to " + resource;
                ParserException ex  = new ParserException(msg, ufe);
                if (null != feedback)
                {
                    feedback.Error(msg, ex);
                }
                throw ex;
            }

            return(ret);
        }
Ejemplo n.º 3
0
 /// <summary> Overriding the constructor to accept the filter
 /// </summary>
 public LinkScanner(string filter) : base(filter, MATCH_NAME, ENDERS, ENDTAG_ENDERS, false)
 {
     processor = new LinkProcessor();
 }
Ejemplo n.º 4
0
 /// <summary> Overriding the constructor to accept the filter
 /// </summary>
 public ImageScanner(string filter, LinkProcessor processor) : base(filter)
 {
     this.processor = processor;
 }
Ejemplo n.º 5
0
 /// <summary> Overriding the default constructor
 /// </summary>
 public ImageScanner() : base()
 {
     processor = new LinkProcessor();
 }
 public BaseHrefScanner(string filter, LinkProcessor processor) : base(filter)
 {
     this.processor = processor;
 }