提供一个网址查询他的title keywords description
可自动辨别这个网址的编码
asp
------解决方案--------------------
<%@ codepage=936 %>
<%
Response.Charset="gb2312"
%>
<script language="jscript" runat="server">
function bs2str(bs,ch){
var re='';
with(new ActiveXObject("adodb.stream")){
type = 1,open(),Write(bs);
Position = 0,Type = 2;
Charset=ch,re=ReadText();
Close()
}
return re;
}
var titReg=/[^>]+(?=<\/title)/i;
var kwReg=/<meta.+?name\s*=\s*['"]?(keywords
------解决方案--------------------
description)\b.+?content\s*=\s*(['"])([^\2]+?)\2/ig;
var chReg=/Charset=([^;]+)/i;
function getInfo(url){
var xh = new ActiveXObject("Microsoft.XMLHttp"),ch,text,re={},ms;
with(xh) open("GET", url, false),send();
ch=chReg.test(xh.getResponseHeader("Content-Type"))?RegExp.$1:'gb2312';
text=/gb2312/i.test(ch)? bs2str(xh.responseBody,ch):xh.responseText;
re.title=text.match(titReg);
while (ms = kwReg.exec(text))re[ms[1].toLowerCase()]=ms[3];
for(var k in re)re[k]=re[k]
------解决方案--------------------
'';
re.html=text
return re;
}
</script>
<%
'''''VBS中调用''''''''''
set info=getInfo("http://www.163.com")
Response.write( info.title & "<br/><br/>")