2012/07/11

c#, html 에서 img src 경로 가져오기


public void getImgs(string _html) {
    Regex rxImages = new Regex("<img.+?src=[\"'](.+?)[\"'].+?>", 
                               RegexOptions.IgnoreCase & RegexOptions.IgnorePatternWhitespace);
    MatchCollection mc = rxImages.Matches(_html);
    foreach(Match m in mc) {
        Console.WriteLine(m.Groups[0].Value);
        Console.WriteLine(m.Groups[1].Value);
    }
}
result: 
0: < img src = "http://yeonpil.org/소녀시대.jpg" / > 
  1: http: //yeonpil.org/소녀시대.jpg


댓글 없음:

댓글 쓰기

가장 많이 본 글