Example Code:
<%
On Error Resume Next
Server.ScriptTimeOut=5
function getHTTPPage(Path)
t = GetBody(Path)
'getHTTPPage=BytesToBstr(t,"iso-8859-1")
getHTTPPage=t
End function
function GetBody(url)
on error resume next
Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get", url, False, "", ""
.Send
GetBody = .ResponseBody
End With
Set Retrieval = Nothing
End function
function reallen(str)
dim l,t,c,i
l=len(str)
t=0
for i=1 to l
c=Abs(Asc(Mid(str,i,1)))
if c>255 then
t=t+2
else
t=t+1
end if
next
reallen=t
end function
url="http://www.alldiy.com"
pagelen=reallen(gethttppage(url))
response.write url&" page length is "&pagelen
%>
--------- tips ---------
for other than English language can use
send("A="&escape(A)&""&escape(B))
just like java
---------improtant note --------
Microsoft.XMLHTTP may not read
root robots.txt for not ASP server site
example Microsoft.XMLHTTP cannot read
google's robots.txt page
Microsoft.XMLHTTP may create diferent result .....
當網頁是中文,日文,韓文等…
英文体以外的文系時,長度可能較
瀏覽器所見的文字數乘2還要長幾倍
|