Recently, there are some collection procedures on the Internet. More people are selling these things on the Internet. Many people who do n’t understand are envious of those programs. In fact, if you understand some ASPs and understand the principle of automatic collection programs, you will feel like you will feel It is so simple to implement automation.
Principles and advantages: Call the webpage on other websites through the XMLHTTP component in XML, and then intercept or replace the original information in batches to transform them into variables and store them in the database one by one. Its main advantage is that there is no need to add a lot of information to hand -made it. You can specify a batch entry of the interception of a certain site information to achieve the purpose of saving time and effort. Different from its simple ASP thief program: it no longer relies on its target website.
Simple example:
The following is the code fragment: <% 'Statement the function of obtaining the target information and implement it through the XML component. Function geturl (url) Setrieval = createObject ("Microsoft.xmlhttp") With retrieval .Open "get", url, false .Send Geturl = bytes2bstr (.Responsebody) 'Verify the information, if the information length is less than 100, it means that the interception fails if len (.Responsebody) <100 that Response.write "Get remote file <a href =" & url & "target = _blank>" & url & "</a> failure." response.end end if End with Setrieval = Nothing End function 'Dual -to -making string, otherwise it 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 'State the format of the interception, starting from Start to the end of LAST 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 SoftID = Request ("ID") Url = "http://www3.skycn.com/soft/" & softid & ".html" Html = geturl (url) 'Taking the software name of the Sky Software as an example Title = getkey (html, "<font color = '#004fc6' size = '3'>", "</font> </td> </tr>) 'Open the database and prepare to enter the library Dim Connstr, Conn, RS, SQL connstr = "dbq =" server.mappath ("db1.mdb") "" "; set conn = server.createObject ("Adodb.connection") conn.open connstr set rs = server.createObject ("Adodb.oldSet") sql = "select [column name] from [watch name] where [column name] = '& title &"' " RS.Oopen SQL, CONN, 3,3 if rs.eof and rs.bof then RS ("" Listing ") = Title rs.update set rs = Nothing end if set rs = Nothing Response.write "Collected!" " %> |
Let's name him getKey.asp for the time being, let's test the intercepted results with this machine (take http://www3.skycn.com/soft/771.html as an example).
Http://127.0.0.1/getKey.asp?id=771