[ASP] Principle and simple example of thief

xiaoxiao2021-03-06  92

Now there are more popular thieves, there are news thieves, music thieves, download thieves, then how do they do it, let me be a brief introduction, I hope to help from the webmasters.

(1) principle

The thief program actually invokes the webpage on other websites through the XMLHTTP components in XML. For example, the news thief program, many of them call the Sina's news page, and some replacements are made, and the advertisements have also been filtered. The advantages of the thief program are: No need to maintain the website, because the data in the thief program is from other websites, which will be updated with the update of the site; save server resources, general thief procedures, all web content is From other websites. Disadvantages: Unstable, if the target website is wrong, the program will make an error, and if the target website is upgraded, then the thieves should be modified accordingly; speed, because it is remote call, speed, and read data on the local server Compared to, it must be slower.

(2) case

Below XMLHTTP's application in ASP, is a brief description

<%

'Common function

'1, enter the URL target web address, return value gethttppage is the HTML code for 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, conversion of Chambar, directly using the web page with Chinese characters with Chinese characters will be Hemma, can be converted via AdoDb.Stream components

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 call HTML content in http://www.fashionme.net

<%

DIM URL, HTML

URL = "http://www.fashionme.net"

HTML = gethttppage (URL)

Response.write HTML

%>

转载请注明原文地址:https://www.9cbs.com/read-103742.html

New Post(0)