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>");
                    }
                }

  • 相关阅读:
    fork安全的gettid高效实现
    TCP_DEFER_ACCEPT的坑
    TCP Linger的坑
    Blade和其他构建工具有什么不同
    在Blade中结合gperftools检查内存泄露
    GraphViz web版
    用户场景分析
    java-二维数组——with 刘童格
    java-四则运算-五-网页版--with刘童格
    java-四则运算-四
  • 原文地址:https://www.cnblogs.com/wenming205/p/1489454.html
Copyright © 2011-2022 走看看