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/" 'counterfeit Referer
. Send
Proxypage = bytestobstr (. responsebody)
End
Set retrieval = nothing
End Function
The bytestobstr process is attached. You can define whether the webpage is UTF-8 or gb2312, and 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
CodeExplanation:
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 ")
It is very useful to forge a referer, but it is useful for some websites. So I added the code and can comment it out,
Note:
If you do not write ASP for collection, you may not understand the code. It is not discussed in this post. I hope it will be useful to you.