Automatically collect programs and code for receiving data in ASP

Source: Internet
Author: User

Recently, some collection programs are popular on the Internet, and more people are selling these items online. Many people who do not know much about them are jealous of those programs. In fact, if you know some ASP, after understanding the principles of the automatic collection program, you will feel that automation is also so simple.
Principle and advantages: the XMLHTTP component in XML is used to call web pages on other websites, and then the original information is intercepted or replaced in batches to convert it into variables and then stored in the database one by one. The main advantage is that you do not need to manually add a large amount of information. You can specify the interception of a certain station information for batch input to save time and effort. Unlike the simple ASP thief program, it no longer depends on its target website.
Simple Example: Copy codeThe Code is as follows: <%
'Declare the function for obtaining the target information and implement it through the XML component.
Geturl (/blog/url)
Set Retrieval = CreateObject ("Microsoft. XMLHTTP ")
With Retrieval
Open "GET", url, False
Send
GetURL = bytes2bstr (. responsebody)
'Verify the obtained information. If the length of the information is smaller than 100, the interception fails.
If len (. responsebody) <100 then
Response. write "failed to get the remote file <a href ="/blog/"& url &" target = _ blank> "& url &" </a>. "
Response. end
End if
End
Set Retrieval = Nothing
End
'Binary to string, otherwise garbled!
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
'Specifies the screenshot format, starting from Start and ending with Last.
GetKey (HTML, Start, Last)
Filearray = split (HTML, Start)
Filearray2 = split (filearray (1), Last)
GetKey = filearray2 (0)
End
Dim Softid, 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)
'Use the software name used to capture the sky as an Example
Title = GetKey (Html, "<font color = '#004FC6 'size = '3'> ", "</font> </B> </td> </tr> ")
'Open the database and prepare for warehouse receiving
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 [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! "
%>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.