欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

ASP下實(shí)現(xiàn)自動(dòng)采集程序及入庫(kù)的代碼

 更新時(shí)間:2007年03月29日 00:00:00   作者:  
最近網(wǎng)上流行著一些采集程序,更多人拿著這些東西在網(wǎng)上叫賣,很多不太懂的人看著那些程序眼羨,其實(shí)如果你懂一些ASP,了解自動(dòng)采集程序的原理后,你會(huì)感覺實(shí)現(xiàn)自動(dòng)化也是那么的簡(jiǎn)單.
原理及優(yōu)點(diǎn):通過XML中的XMLHTTP組件調(diào)用其它網(wǎng)站上的網(wǎng)頁,然后批量截取或替換原有的信息使其轉(zhuǎn)化成變量后再一一儲(chǔ)存到數(shù)據(jù)庫(kù)中。其主要的優(yōu)點(diǎn)便是無需再手工添加大量的信息了,可以指定對(duì)某一個(gè)站信息的截取進(jìn)行批量錄入,達(dá)到省時(shí)省力的目的。與其單純的ASP小偷程序不同的是:它已經(jīng)不再依賴其目標(biāo)網(wǎng)站。
簡(jiǎn)單事例:
復(fù)制代碼 代碼如下:

 <% 
 '聲明取得目標(biāo)信息的函數(shù),通過XML組件進(jìn)行實(shí)現(xiàn)。 
  Geturl(/blog/url)  
 Set Retrieval = CreateObject("Microsoft.XMLHTTP")  
 With Retrieval  
 Open "GET", url, False 
 Send  
 GetURL = bytes2bstr(.responsebody) 
 '對(duì)取得信息進(jìn)行驗(yàn)證,如果信息長(zhǎng)度小于100則說明截取失敗 
if len(.responsebody)<100 then 
response.write "獲取遠(yuǎn)程文件 <a href="/blog/"&url&" target=_blank>"&url&"</a> 失敗。" 
response.end 
end if 
End With  
Set Retrieval = Nothing  
End  
' 二進(jìn)制轉(zhuǎn)字符串,否則會(huì)出現(xiàn)亂碼的! 
 bytes2bstr(vin)  
strreturn = ""  
for i = 1 to lenb(vin)  
thischarcode = ascb(midb(vin,i,1))  
if thischarcode < &h80 then  
strreturn = strreturn & chr(thischarcode)  
else  
nextcharcode = ascb(midb(vin,i+1,1))  
strreturn = strreturn & chr(clng(thischarcode) * &h100 + cint(nextcharcode))  
i = i + 1  
end if  
next  
bytes2bstr = strreturn  
end   
'聲明截取的格式,從Start開始截取,到Last為結(jié)束 
 GetKey(HTML,Start,Last) 
filearray=split(HTML,Start) 
filearray2=split(filearray(1),Last) 
GetKey=filearray2(0) 
End  
Dim Softid,Url,Html,Title  
'獲取要取頁面的ID 
SoftId=Request("Id") 
  Url="http://www3.skycn.com/soft/"&SoftId&".html"  
  Html = Geturl(/blog/Url)  
'以截取天空軟件的軟件名為例子 
  Title = GetKey(Html,"<font color='#004FC6' size='3'>","</font></b></td></tr>") 
'打開數(shù)據(jù)庫(kù),準(zhǔn)備入庫(kù) 
dim connstr,conn,rs,sql 
connstr="DBQ="+server.mappath("db1.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};" 
set conn=server.createobject("ADODB.CONNECTION") 
conn.open connstr 
set rs=server.createobject("adodb.recordset") 
sql="select [列名] from [表名] where [列名]='"&Title&"'" 
rs.open sql,conn,3,3 
if rs.eof and rs.bof then  
rs("列名")=Title 
rs.update  
set rs=nothing 
end if 
set rs=nothing 
Response.Write"采集完畢!" 
%>

相關(guān)文章

最新評(píng)論