ASP读取<a>与</a>之间的代码
例如新闻列表:<ahref="/news/123.html">新闻1</a><ahref="/news/234.html">新闻2</a><ahref="/news/34...
例如新闻列表:<a href="/news/123.html">新闻1</a><a href="/news/234.html">新闻2</a><a href="/news/345.html">新闻3</a>用ASP如何读取并列出来如下新闻链接 新闻标题/news/123.html 新闻1/news/234.html 新闻2/news/345.html 新闻3
展开
3个回答
2013-10-27
展开全部
这是前端代码,要用javascript 读取。你可以参看参看 <a id='a1' href="/news/123.html">新闻1</a><a id='a2' href="/news/234.html">新闻2</a><a id='a3' href="/news/345.html">新闻3</a>
<p>
以下是读出的数据
<div id='a1h'></div>
<div id='a2h'></div>
<div id='a3h'></div>
<p>
<div id='a1s'></div>
<div id='a2s'></div>
<div id='a3s'></div>
<script>
function reada(id){
return(document.getElementById(id).innerHTML);
}
function readH(id){
return(document.getElementById(id).href);
}
document.getElementById('a1h').innerHTML=reada('a1');
document.getElementById('a2h').innerHTML=reada('a2');
document.getElementById('a3h').innerHTML=reada('a3');document.getElementById('a1s').innerHTML=readH('a1');
document.getElementById('a2s').innerHTML=readH('a2');
document.getElementById('a3s').innerHTML=readH('a3');
</script>
<p>
以下是读出的数据
<div id='a1h'></div>
<div id='a2h'></div>
<div id='a3h'></div>
<p>
<div id='a1s'></div>
<div id='a2s'></div>
<div id='a3s'></div>
<script>
function reada(id){
return(document.getElementById(id).innerHTML);
}
function readH(id){
return(document.getElementById(id).href);
}
document.getElementById('a1h').innerHTML=reada('a1');
document.getElementById('a2h').innerHTML=reada('a2');
document.getElementById('a3h').innerHTML=reada('a3');document.getElementById('a1s').innerHTML=readH('a1');
document.getElementById('a2s').innerHTML=readH('a2');
document.getElementById('a3s').innerHTML=readH('a3');
</script>
2013-10-27
展开全部
你的意思是说提取HTML源码中所有A标签的href的值与标题吗? Dim HTMLcode
HTMLcode="HTML源码.........."
Dim regEx, Match, Matches,ImgStr,ImgArr
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
regEx.Pattern = "<a .*?href=""(.*?)"".*?>(.*?)</a>"
response.write "新闻链接 新闻标题"
Set Matches = regEx.Execute(HTMLcode)
For Each Match in Matches' 遍历所有a标签。
response.write Match.SubMatches(0) & " " & Match.SubMatches(1) & "<br>" '输出URL 与 标题
Next
HTMLcode="HTML源码.........."
Dim regEx, Match, Matches,ImgStr,ImgArr
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
regEx.Pattern = "<a .*?href=""(.*?)"".*?>(.*?)</a>"
response.write "新闻链接 新闻标题"
Set Matches = regEx.Execute(HTMLcode)
For Each Match in Matches' 遍历所有a标签。
response.write Match.SubMatches(0) & " " & Match.SubMatches(1) & "<br>" '输出URL 与 标题
Next
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-10-27
展开全部
<a href="/news/123.html">新闻1</a> <a href="/news/234.html">新闻2</a> <a href="/news/345.html">
新闻3</a> <script type="text/javascript">
var str = "";
var obj = document.getElementsByTagName("a");
for (var i = 0; i < obj.length; i++) {
str += obj[i].href + " " + obj[i].innerHTML + "\n";
} alert(str);
</script>
新闻3</a> <script type="text/javascript">
var str = "";
var obj = document.getElementsByTagName("a");
for (var i = 0; i < obj.length; i++) {
str += obj[i].href + " " + obj[i].innerHTML + "\n";
} alert(str);
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询