Acquisition
Recently on the Internet a number of collection procedures, more people holding these things online, many people who do not know how to look at those procedures to envy, in fact, if you understand some ASP, understand the principle of automatic acquisition program, you will feel the automation is also so simple.
Principle and Advantages: the XMLHTTP component in the XML is invoked on other Web pages, then the batch intercepts or replaces the original information so that it is converted into a variable and then one by one is stored in the database. The main advantage is that no need to manually add a lot of information, you can designate a station information interception for batch input, to save time and effort. Unlike the Simple ASP Thief program, it is no longer dependent on its target site.
Simple example:
<% ' Declares a function that obtains the target information, which is implemented through an XML component. Function GetURL (URL) Set retrieval = CreateObject ("Microsoft.XMLHTTP") With retrieval . Open ' get ', url, False . Send GetURL = Bytes2bstr (. responsebody) ' Verify the acquisition information, if the information length is less than 100, the interception failed If Len (. responsebody) <100 Then Response.Write "Get remote file <a href=" &url& "target=_blank>" &url& "</a> failed. " Response.End End If
End With Set retrieval = Nothing End Function ' Binary turn string, otherwise there will be garbled! function 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 Function ' Declaration of interception format, from start to intercept, to last to end Function Getkey (Html,start,last) Filearray=split (Html,start) Filearray2=split (Filearray (1), last) Getkey=filearray2 (0) End Function
Dim Softid,url,html,title
' Get the ID of the page you want to take
Softid=request ("Id")
Url= "http://www3.skycn.com/soft/" &SoftId& ". html"
Html = GetURL (URL)
' Software name for intercepting Sky Software as an example
Title = Getkey (Html, "<font color= ' #004FC6 ' size= ' 3 ' >", "</font></b></td></tr>")
' Open database, prepare for storage
Dim connstr,conn,rs,sql
Connstr= "dbq=" +server.mappath ("Db1.mdb") + ";D efaultdir=;D river={microsoft Access DRIVER (*.mdb)};"
Set Conn=server.createobject ("ADODB. CONNECTION ")
Conn.Open ConnStr
Set Rs=server.createobject ("Adodb.recordset")
Sql= "SELECT [column name] from [table name] where [column name]= '" ' &Title& ' "
Rs.Open sql,conn,3,3
If rs.eof and Rs.bof then
RS ("column name") =title
Rs.update
Set rs=nothing
End If
Set rs=nothing
Response.Write "Collection completed!"
%> |