zoukankan      html  css  js  c++  java
  • c#从html中获取图片地址

     using System.Text.RegularExpressions;

    string ohtml = this.TextBox1.Text;
                System.Text.RegularExpressions.MatchCollection m;
                //提取字符串的图片
                m = Regex.Matches(ohtml, "(<img).*?>");
                for (int i = 0; i < m.Count; i++)
                {
                    string ostr = m[i].ToString();
                    //提取图片的地址
                    System.Text.RegularExpressions.MatchCollection m2;
                    m2 = Regex.Matches(ostr, "(src=)['|\"].*?['\"]");
                    for (int j = 0; j < m2.Count; j++)
                    {
                        string strTemp = m2[j].ToString();
                        strTemp = strTemp.Replace("src=", "");
                        strTemp = strTemp.Replace("\"", "");
                        strTemp = strTemp.Replace("'", "");
                        Response.Write(strTemp+ "<br>");
                    }
                }

  • 相关阅读:
    LightOJ 1300 边双联通分量+交错路染色
    HDU 6143 快速幂,组合数
    windows 下fc工具
    HDU 6136 模拟
    HDU 6129 暴力,规律
    UVA Live 7770 模拟
    1096: [ZJOI2007]仓库建设
    1191: [HNOI2006]超级英雄Hero
    3224: Tyvj 1728 普通平衡树
    1208: [HNOI2004]宠物收养所
  • 原文地址:https://www.cnblogs.com/wenming205/p/1489454.html
Copyright © 2011-2022 走看看