string text1 = this.TextBox1.Text.Trim();
MatchCollection collection1 = new Regex("<img.+?>", RegexOptions.IgnoreCase).Matches(text1);
string text2 = "";
foreach (Match match1 in collection1)
{
text2 = this.GetHttp(match1.Value);
this.DownloadFile(text2);
}
public string GetHttp(string str)
{
Match match1 = new Regex("http://.+?/"", RegexOptions.IgnoreCase).Match(str);
return match1.Value.Substring(0, match1.Value.Length - 1);
}
本文介绍了一种使用C#从文本中提取所有图片标签的方法,并通过正则表达式获取图片的HTTP链接,最后将这些图片下载到本地。该过程涉及字符串处理、正则表达式的应用及文件下载等功能。

1119

被折叠的 条评论
为什么被折叠?



