Core Function Code collected by ASP proxy

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.