如何获取网页标题的ASP代码
<%
Function getHTTPPage(url)
on error resume next
dim http
set http=Server.createobject("Msxml2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytes2BSTR(Http.responseBody)
set http=nothing
if err.number<>0 then
err.Clear
end if
End Function
Function bytes2BSTR(vIn)
dim strReturn
dim i,ThisCharCode,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
Function GetPageTitle(HtmlContent)
Dim l,j,strTitle
l = InStr(LCase(HtmlContent), "<title>")
If l > 0 Then
l = l + 7
j = InStr(l, LCase(HtmlContent), "</title>")
If j > 0 Then
strTemp = Mid(HtmlContent, l, j - l)
Else
strTemp = "无法获取网页标题!"
End If
Else
strTemp = "无法获取网页标题!"
End If
GetPageTitle = strTemp
End Function
Title = GetPageTitle(HtmlCldeContent)
response.write(Title)
%>
因尔特网络数据中心 18年老牌idc服务商为你提供云主机、高防服务器、虚拟主机、域名、网站建设、APP制作、SSL证书等,欢迎咨询!