当前位置: 首页 > 图文教程 > 网络编程 > ASP > asp代理采集的核心函数代码

ASP
asp使用activex组件实例一
ASP中检查没有数据提交的页面Ⅰ
ASP中检查没有数据提交的页面Ⅱ
为ASP开发者介绍ColdFusion
W3 Jmail 简要介绍
W3 Jmail 参考说明
W3 Jmail 使用范例
ASP教程:堵住ASP漏洞
利 用 ASP 开 发 网 络 聊 天 室
MySQL数据库基础教程
ASP和SQLServer时间处理方法Ⅰ
如何利用ASP实现邮箱访问
SQL语言快速入门之一
SQL语言快速入门之二
SQL语言快速入门之三(一)
用纯ASP代码实现图片上传并存入数据库中
ASP进阶教程Ⅹ:留言簿自动发E-Mail
单元测试和事先测试开发(2)
.NET的事务控制.
.NET 的数据访问应用程序块(Data Access Application Block)

ASP 中的 asp代理采集的核心函数代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 304 ::
收藏到网摘: n/a

如果你不会写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 "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用处很一般,不过对于一些站还是有用的,所以代码我加上了,可以注释掉,
注意:
如果你不会写asp采集,那么代码你可能不懂,那就不是我这次发帖所讨论了,希望对大家有用。