If you don't know how to write ASP collection, then you may not understand the code, which is not what I am discussing in this post. I hope it is useful to everyone. Function ProxyPage(url)
Set Retrieval = CreateObject(MSXML2.ServerXMLHTTP.5.0)
With Retrieval
.SetProxy 2, 255.0.0.0:80 'Proxy ip: proxy port
.Open Get, url, False, ,
.setRequestHeader Referer,http://www.baidu.com/ 'Fake referer
.Send
ProxyPage = BytesToBstr(.ResponseBody)
End With
Set Retrieval = Nothing
End Function
Attached is the BytesToBstr process. When collecting, you can define whether the web page is utf-8 or gb2312. utf=True is utf-8.
Function BytesToBstr(body)
dim objstream
set objstream = Server.CreateObject(ad&&odb.st&&ream)
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
if utf=True then
objstream.Charset = utf-8
else
objstream.Charset = gb2312
end if
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Code explanation:
If your system is win 2003, you can only use the following code
CreateObject(MSXML2.ServerXMLHTTP.4.0)
If it is xp
CreateObject(MSXML2.ServerXMLHTTP.5.0)
The use of fake referer is very general, but it is still useful for some websites, so I added the code and you can comment it out.
Notice:
If you don't know how to write ASP collection, then you may not understand the code, which is not what I am discussing in this post. I hope it is useful to everyone.