asp代理采集的核心函數(shù)代碼
更新時(shí)間:2008年10月04日 23:53:35 作者:
如果你不會(huì)寫asp采集,那么代碼你可能不懂,那就不是我這次發(fā)帖所討論了,希望對(duì)大家有用。
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過程,你采集的時(shí)候可以定義網(wǎng)頁是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
代碼解釋:
如果你系統(tǒng)是win 2003 只能使用以下代碼
CreateObject("MSXML2.ServerXMLHTTP.4.0")
若為xp
CreateObject("MSXML2.ServerXMLHTTP.5.0")
偽造referer用處很一般,不過對(duì)于一些站還是有用的,所以代碼我加上了,可以注釋掉,
注意:
如果你不會(huì)寫asp采集,那么代碼你可能不懂,那就不是我這次發(fā)帖所討論了,希望對(duì)大家有用。
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過程,你采集的時(shí)候可以定義網(wǎng)頁是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
代碼解釋:
如果你系統(tǒng)是win 2003 只能使用以下代碼
CreateObject("MSXML2.ServerXMLHTTP.4.0")
若為xp
CreateObject("MSXML2.ServerXMLHTTP.5.0")
偽造referer用處很一般,不過對(duì)于一些站還是有用的,所以代碼我加上了,可以注釋掉,
注意:
如果你不會(huì)寫asp采集,那么代碼你可能不懂,那就不是我這次發(fā)帖所討論了,希望對(duì)大家有用。
相關(guān)文章
利用MSXML2.XmlHttp和Adodb.Stream采集圖片
asp下經(jīng)常用來采集的兩個(gè)組件結(jié)合使用例子2008-05-05
實(shí)例講解實(shí)現(xiàn)抓取網(wǎng)上房產(chǎn)信息的ASP程序
實(shí)例講解實(shí)現(xiàn)抓取網(wǎng)上房產(chǎn)信息的ASP程序...2007-03-03
msxml3.dll 錯(cuò)誤 800c0005 解決方案
在運(yùn)用xmlhttp組件編寫程序中,會(huì)碰到msxml3.dll 錯(cuò)誤 800c0005系統(tǒng)未找到指定的資源。這種錯(cuò)誤,網(wǎng)上對(duì)這種錯(cuò)誤的產(chǎn)生原因有很多鐘解釋,大體說是因?yàn)榉阑饓騏DP站口權(quán)限造成了,也說了相應(yīng)的解決辦法2006-08-08

