加入收藏 | 设为首页 | 会员中心 | 我要投稿 汽车网 (https://www.0577qiche.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

asp代理收集的核心函数代码

发布时间:2023-08-21 13:11:56 所属栏目:Asp教程 来源:
导读:Function ProxyPage(url)
Set Retrieval = CreateObject("MSXML2.ServerXMLHTTP.5.0")
With Retrieval
.SetProxy 2 , "255.0.0.0:80" '代理ip:代理端口
.Open "Get", url, False, "", ""
.setRequestHeader
Function ProxyPage(url)
Set Retrieval = CreateObject("MSXML2.ServerXMLHTTP.5.0")
With Retrieval
.SetProxy 2 , "255.0.0.0:80" '代理ip:代理端口
.Open "Get", url, False, "", ""
.setRequestHeader "Referer","http://www.baidu.com/" '伪造referer
.Send
ProxyPage = BytesToBstr(.ResponseBody)
End With
Set Retrieval = Nothing
End Function

附BytesToBstr过程,你采集的时候可以定义网页是utf-8还是gb2312,utf="True"为 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
代码解释:
如果你系统是win 2003 只能使用以下代码
CreateObject("MSXML2.ServerXMLHTTP.4.0")
若为xp
CreateObject("MSXML2.ServerXMLHTTP.5.0")

伪造referer用处很一般,不过对于一些站还是有用的,所以代码我加上了,可以注释掉
 

(编辑:汽车网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章