Get all the pictures in HTML URL

///  <the Summary> 
        /// Gets all the pictures in the HTML URL
         ///  </ the Summary> 
        ///  <param name = "strHTML"> HTML Code </ param> 
        ///  <returns A> image URL list </ Returns> 
        public  static  String [] GetHtmlImageUrlArr ( String strHTML) 
        { 
            // definition of the regular expression to match img tag    
            the regex regImg = new new the regex ( @ " <img \ B [^ <>] *? \ BSRC [\ S \ t \ r \ n] * = [\ s \ t \ r \ n] * [ "" ']? [\ s \ t \ r \ n] * (? <imgUrl> [^ \ s \ t \ r \ n-""?? '<>] *) [^ <>] * / [\ S \ T \ R & lt \ n-] *> " , RegexOptions.IgnoreCase);

            // search for matching strings   
            The matches = the MatchCollection regImg.Matches (strHTML);
             int I = 0 ;
             String [] = sUrlarr new new  String [matches.Count]; 

            // obtain the list of matches    
            the foreach (Match match in The matches) 
                sUrlarr [I ++] = match. Groups [ " for imgUrl " ] .Value;
             return sUrlArr; 
        }

 

Guess you like

Origin www.cnblogs.com/sanday/p/11367255.html