An introductory tutorial for ASP Thieves (remote Data acquisition) programs

Source: Internet
Author: User
"Thieves" here refers to the use of XML in the ASP XMLHTTP components to provide a powerful function, the remote Web site data (Pictures, Web pages and other files) crawled to the local, after a variety of processing to display on the page or stored into the database of a class of programs. You can use this kind of thief program to accomplish some seemingly impossible tasks in the past, such as cynical a page of a station to become your own page, or save some data (articles, pictures) of a station to the local database. The advantages of "thieves" are: no need to maintain the site, because the Thief program data from other sites, it will be updated with the site update, you can save a lot of server resources, the General Thief program on several files, all Web content is from other sites. The disadvantage is: instability, if the target site error, the program will also be wrong, and, if the target site to upgrade maintenance, then the Thief program to make corresponding changes; speed, because it is a remote call, speed and on the local server reading data than it is certainly slower. What, it sounds amazing, doesn't it? Let's start by learning some of the basics of "thief" programs.
Let's take a simple point to study the weather forecast program on the QQ website
The code is as follows:
<%
On Error Resume Next
server.scripttimeout=9999999
Function Gethttppage (Path)
t = GetBody (Path)
Gethttppage=bytestobstr (T, "GB2312")
End Function
' First of all, to carry out some initialization of the Thief program, the role of the above code is to ignore all non-fatal errors, the Thief program's running timeout time set very long (so do not run timeout error), converted to the original default UTF-8 encoding to GB2312 encoding, Otherwise, directly using the XMLHTTP component to invoke a page with Chinese characters will be garbled.
Function getbody (URL)
On Error Resume Next
Set retrieval = CreateObject ("Microsoft.XMLHTTP")
With retrieval
. Open "Get", url, False, "", ""
. Send
GetBody =. Responsebody
End With
Set retrieval = Nothing
End Function
' Then call the XMLHTTP component to create an object and initialize the settings.
Function Bytestobstr (Body,cset)
Dim objstream
Set objstream = Server.CreateObject ("ADODB.stream")
Objstream. Type = 1
Objstream. Mode =3
Objstream. Open
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.