out
13
2011
13
2011
ASP.NET – Pegando o caminho da imagem a partir do HTML
Olá pessoal, estou aqui para mostrar um método relativamente simples mas  muito útil. Pegar o caminho de uma imagem a partir de um conjunto de tags HTML com C#.
Vamos lá:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | public string GetImageScr(string conteudoHtml) { string regexImgSrc = @"<img[^>]*?src\s*=\s*[""']?([^'"" >]+?)[ '""][^>]*?>"; MatchCollection matchesImgSrc = Regex.Matches(conteudoHtml, regexImgSrc, RegexOptions.IgnoreCase | RegexOptions.Singleline); string src = string.Empty; try { Match m = matchesImgSrc[0]; src = m.Groups[1].Value; } catch { } return src; } |

An article by






Estava precisando justamente disso.
Obrigado, continue assim!!!
Obs: manja em!!!