zoukankan
html css js c++ java
复写page的Render方法
public
class
SetToken :System.Web.UI.Page
{
protected
override
void
Render(System.Web.UI.HtmlTextWriter writer)
{
StringWriter sw
=
new
StringWriter();
HtmlTextWriter htmlWriter
=
new
HtmlTextWriter(sw);
base
.Render(htmlWriter);
string
html
=
sw.ToString() ;
Regex obj
=
new
Regex(
"
<a.*?(?: |\\\\t|\\\\r|\\\\n)?href=[\\'\
"
]
?
(.
+?
)[\\
'
\"]?(?:(?: |\\\\t|\\\\r|\\\\n)+.*?)?>(.+?)<\\/a.*?>", RegexOptions.IgnoreCase | RegexOptions.Compiled);
MatchCollection matches
=
obj.Matches(html);
CompareList list
=
new
CompareList();
foreach
(Match match
in
matches)
{
string
url
=
match.Groups[
1
].Value.ToLower();
list.Add(url);
}
foreach
(
string
url
in
list)
{
string
newUrl
=
Utils.WriteUrl(url);
html
=
html.Replace(url, newUrl);
}
writer.Write(html) ;
}
}
该代码实现了复写page的rander方法,给解析出来的超链接统一添加token标记。页面使用在页面上继承这个类就可以了。
查看全文
相关阅读:
hdu 1690
hdu 2962
hdu 2923
hdu 1385
hdu 1505
python:获取访问访问时的响应时间
自动化脚本编写环境部署_win7(RF)
python操作浏览器及截图小结
Python + Selenium 实现对页面的指定元素截图(可截长图元素)【转载】
Linux:DNS服务器搭建及配置
原文地址:https://www.cnblogs.com/yg_zhang/p/1134596.html
最新文章
[LeetCode]Maximum Depth of Binary Tree
[LeetCode]Contains Duplicate III
[LeetCode]Ugly Number II
Strassen矩阵算法分析及其C++实现 递归分治法(转)
C++primer plus第十章第5题
类和动态内存管理注意的几个问题
《C++ Primer Plus》第6版重点笔记
打印
源码解读Mybatis List列表In查询实现的注意事项
基于JSP 自定义标签使用实例介绍
热门文章
The connection to adb is down, and a severe error has occured.问题解决
【MyBatis】实现批量删除,比较通用
关于多表的leftJoin(转)
jquery 获取和设置 select下拉框的值
jQuery的选择器中的通配符[id^='code']或[name^='code']
hdu 3191
hdu 1688
hdu 2363
hdu 1598
hdu 1596
Copyright © 2011-2022 走看看