ASP thief program principle and simple example

Source: Internet
Author: User
Program | example | Thief program

(i) principle

The thief program actually invokes pages on other Web sites through the XMLHTTP component in the XML. For example, the News thief program, many are called Sina's news page, and some of the HTML is replaced, while the ads also filtered. The advantages of using a thief program are: no maintenance site, because the Thief program data from other sites, it will be updated with the site update, you can save server resources, the General Thief program on several files, all Web content is from other sites. Disadvantages are: 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 the corresponding changes; speed, because it is a remote call, speed and read data on the local server, it must be slower.

  (ii) case

The following is a brief description of the application of XMLHTTP in ASP

〈%

' Common functions

' 1, enter URL target page address, return value Gethttppage is the HTML code of the target page

function gethttppage (URL)

Dim Http

Set Http=server.createobject ("MSXML2. XMLHTTP ")

Http.open "Get", Url,false

Http.send ()

If Http.readystate <> 4 Then

Exit function

End If

Gethttppage=bytestobstr (Http.responsebody, "GB2312")

Set http=nothing

If Err.Number <> 0 then err. Clear

End Function

' 2, the conversion of XMLHTTP, directly with the use of Chinese characters to call the Web page will be chaos, can be converted through the ADODB.stream component

Function Bytestobstr (Body,cset)

Dim objstream

Set objstream = Server.CreateObject ("ADODB.stream")

Objstream. Type = 1

Objstream. Mode =3

Objstream. Open

Objstream. Write body

Objstream. Position = 0

Objstream. Type = 2

Objstream. Charset = Cset

Bytestobstr = objstream. ReadText

Objstream. Close

Set objstream = Nothing

End Function

' Try to invoke http://www.webjx.com/earticle/HTML content below

Dim url,html

Url= "http://www.webjx.com/earticle/"

Html = Gethttppage (URL)

Response.Write Html

%〉



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.