苏飞论坛

标题: 【HttpHelper万能框架教程】过滤所有的换行符号 [打印本页]

作者: 站长苏飞    时间: 2014-9-11 09:32
标题: 【HttpHelper万能框架教程】过滤所有的换行符号
导读部分

【HttpHelper万能框架】教程目录贴  http://www.sufeinet.com/thread-9989-1-1.html


教程部分


在开发过程中,我们时不时的会用到要过滤换行符号的功能。为了方便大家使用,我把这个方法集成到了万能框架中。方便大家调用。

方法签名如下
[C#] 纯文本查看 复制代码
          /// <summary>        /// 过滤html中所有的换行符号
        /// </summary>
        /// <param name="html">html的内容</param>
        /// <returns>处理后的文本</returns>
        public static string ReplaceNewLine(string html)


直接输入Html,就会返回过滤后的数据
看代码
[C#] 纯文本查看 复制代码
            //创建Httphelper对象
            HttpHelper http = new HttpHelper();
            //创建Httphelper参数对象
            HttpItem item = new HttpItem()
            {
                URL = "http://www.sufeinet.com",//URL     必需项   
                Method = "get",//URL     可选项 默认为Get   
                ContentType = "text/html",//返回类型    可选项有默认值   
                //ContentType = "application/x-www-form-urlencoded",//返回类型    可选项有默认值   
            };
            //请求的返回值对象
            HttpResult result = http.GetHtml(item);
            //获取请请求的Html
            string html = result.Html;

            html = HttpHelper.ReplaceNewLine(html);
效果
处理之前
(, 下载次数: 216)