时间:2016-02-15 22:11 来源: 我爱IT技术网 作者:佚名
欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【asp.net(c#)获取内容第一张图片地址的函数】,下面是详细的讲解!
asp.net(c#)获取内容第一张图片地址的函数
/// <summary>
/// 获取文中图片地址
/// </summary>
/// <param name="content">内容</param>
/// <returns>地址字符串</returns>
public static string getImageUrl(string content)
{
int mouse=0;
int cat=0;
string imageLabel="";
string imgSrc="";
string[] Attributes;
do //得到第一张图片的连接作为主要图片
{
cat=content.IndexOf("<IMG", mouse);
mouse=content.IndexOf('>', cat);
imageLabel=content.Substring(cat, mouse - cat); //图像标签
Attributes=imageLabel.Split(' '); //将图片属性分开
foreach (string temp_Attributes in Attributes) //得到图片地址属性
if (temp_Attributes.IndexOf("src") >=0)
{
imgSrc=temp_Attributes.ToString();
break;
}
imgSrc=imgSrc.Substring(imgSrc.IndexOf('"') + 1, imgSrc.LastIndexOf('"') - imgSrc.IndexOf('"') - 1); //丛地址属性中提取地址
} while (imgSrc=="" && cat > 0);
return (imgSrc);
}
关于asp.net(c#)获取内容第一张图片地址的函数的用户互动如下:
相关问题:
答: >>详细
相关问题:
答: >>详细
相关问题:
答: >>详细
- 【asp】asp.net url重写浅谈-net-url重写
- 【DataSet】DataSet、DataTable、DataRow区别详解
- 【创建】ASP.NET Web API教程 创建域模型的方法详
- 【asp】asp.net ubb使用代码-net-ubb使用
- 【默认图片】图片不存在使用默认图片代替的实例
- 【页面打印】关于ASP.NET页面打印技术的常用方法
- 【MVC5】MVC 5 第一章 创建MVC 5 web应用程序-net
- 【MVC】一个简单MVC5 + EF6示例分享-EF6实例-MVC5
- 【服务器】asp.net页面状态管理cookie和服务器状
- 【asp】asp.net更新指定记录的方法-net--更新-指
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
