Recently, some collection programs are popular on the Internet. More people are selling these things online. Many people who don’t know much are envious of those programs. In fact, if you understand some ASP and understand the principles of automatic collection programs, you will feel that it is so simple to implement automation.
Principle and advantages: Through the XMLHTTP component in XML, the web pages on other websites are called, and then batch intercept or replace the original information so that it is converted into variables and then stored in the database one by one. Its main advantage is that there is no need to manually add a large amount of information. You can specify the interception of a certain site information and batch input to achieve the purpose of saving time and effort. Unlike its purely ASP thief program: it no longer relies on its target website.
Simple examples:
The code copy is as follows:
<%
'Declare the function to obtain the target information and implement it through XML components.
Geturl(/blog/url)
SetRetrieval=CreateObject("Microsoft.XMLHTTP")
WithRetrieval
Open"GET",url,False
Send
GetURL=bytes2bstr(.responsebody)
'Verify the obtained information. If the information length is less than 100, it means that the interception failed
iflen(.responsebody)<100then
response.write"Failed to get remote file <ahref="/blog/"&url&"target=_blank>"&url&"</a>. "
response.end
endif
EndWith
SetRetrieval=Nothing
End
'Turn binary to string, otherwise garbled will appear!
bytes2bstr(vin)
strreturn=""
fori=1tolenb(vin)
thischarcode=ascb(midb(vin,i,1))
ifthischarcode<&h80then
strreturn=strreturn&chr(thischarcode)
else
nextcharcode=ascb(midb(vin,i+1,1))
strreturn=strreturn&chr(clng(thischarcode)*&h100+cint(nextcharcode))
i=i+1
endif
next
bytes2bstr=strreturn
end
'Declare the intercepted format, start from Start and end at Last
GetKey(HTML, Start, Last)
filearray=split(HTML,Start)
filearray2=split(filearray(1),Last)
GetKey=filearray2(0)
End
DimSoftid, Url, Html, Title
'Get the ID of the page to be retrieved
SoftId=Request("Id")
Url="http://www3.skycn.com/soft/"&SoftId&".html"
Html=Geturl(/blog/Url)
'Take the software name of the intercepting Sky software as an example
Title=GetKey(Html,"<fontcolor='#004FC6'size='3'>","</font></b></td></tr>")
'Open the database and prepare to enter the database
dimconnstr,conn,rs,sql
connstr="DBQ="+server.mappath("db1.mdb")+";DefaultDir=;DRIVER={Microsoft AccessDriver(*.mdb)};"
setconn=server.createobject("ADODB.CONNECTION")
conn.openconnstr
setrs=server.createobject("adodb.recordset")
sql="select[column name] from[table name] where[column name]='"&Title&"'"
rs.opensql,conn,3,3
ifrs.eofandrs.bofthen
rs("column name")=Title
rs.update
setrs=nothing
endif
setrs=nothing
Response.Write "Collection is complete!"
%>