Principles and simple examples of thieves
Published by: 164720-4-13 Source: yourblog.org)
Nowadays, there are many popular thieves on the Internet, such as news thieves, music thieves, and download thieves. How do they do this? I will give a brief introduction below, I hope it will be helpful to all webmasters.
(1) Principles
Small
The program is actually using the XMLHTTP component in XML to call webpages on other websites. For example, many of the news thief programs call Sina's news pages and
After some replacement, the advertisement is also filtered. The advantages of using the thief program are: No need to maintain the website, because the data in the thief program comes from other websites, it will be updated with the updates of the website; can save the server
Server resources. Generally, the thief program has several files, and all webpage content comes from other websites. Disadvantages: unstable. If an error occurs on the target website, the program will also go wrong. If the target website is upgraded and maintained,
Then the thief program must be modified accordingly. The speed, because it is a remote call, must be slower than reading data on the local server.
(2) Examples
The following is a brief description of the Application of XMLHTTP in ASP.
XML-related technical materials
XMLHTTP Technology
----------------------------------------------------------
I. Remote Database Management Technology
Remote database monitoring is an important part of modern Internet-Based WAN applications. First, let's briefly review the development process and methods of the remote database management technology on the Internet:
Early Database Remote Management by writing CGI-BIN module. But the CGI-BIN running speed is slow, maintenance is inconvenient, and now has been basically abandoned.
Over the past few years, there have been a lot of applications using the Component Object Model (COM), and the results are also very good. However, if a third-party server is used (the author's website is built on a third-party virtual host), the server often does not allow users to register their own components for confidentiality or other commercial reasons.
In recent years, Microsoft launched the. NET platform and Sun's J2EE platform are both very high-end remote database management and service platforms. It can provide excellent multi-tier (n-tier) application services.
Its
. Net Simple Object Access Protocol (SOAP)
Transfer Protocol, HTTP) and extensible Markup Language,
XML) technology implementation across systems (such as Windows-
Linux) communication services have been widely accepted and used by developers. Many large applications, such as enterprise resource planning,
ERP) are built on such a large platform.
However, for small and medium-sized applications, such as the construction and maintenance of a website, such a large application platform seems to be too costly.
Microsoft, once lagging behind in Internet technology and Java technology, is ahead in XML application development. The XMLHTTP protocol in her XML Parser (MSXML) is
A very convenient and practical client service communication pipeline. Use XMLHTTP and ActiveX Data Objects (ActiveX Data Objects,
Adoadox) allows you to easily and remotely manage databases.
This article describes how to use XMLHTTP and adoadox to manage remote databases.
2. Database Remote Management System
The task process of remote database management is as follows:
1. The client sends a command to the server to query or modify the database structure and data.
2. The server accepts and executes the relevant commands and returns the results to the client.
3. The client accepts and displays the command execution result returned by the server.
Two key steps for achieving remote database management are:
1. The data channel for command upload and result transfer between the client and the server is implemented by XMLHTTP.
2. The Command Transmission and result return between the server and the database are completed by the adoadox interface serving as the intermediate layer.
Iii. Use of XMLHTTP
As the name implies, XMLHTTP is a hypertext transfer protocol for transmitting XML data.
In fact, the data transmission process of XMLHTTP is more flexible:
It can upload instructions in XML format, strings, streams, or an unsigned integer array. It can also be a URL parameter.
The output result can be XML data, a string, a stream, or an unsigned integer array.
For more information, see the link at the end of the article.
The client calls XMLHTTP in five steps:
1. Create an XMLHTTP object
2. Open the connection with the server, and define the command sending method, Service webpage (URL), and request permissions.
The client opens a connection to the Service webpage of the server through the open command. Like normal HTTP Command Transmission, you can use the get or POST method to direct to the Service webpage of the server.
3. Send commands.
4. Wait for and receive the processing results returned by the server.
5. Release the XMLHTTP object
XMLHTTP method:
Open bstrmethod, bstrurl, varasync, bstruser, bstrpassword
Bstrmethod: data transmission method, that is, get or post.
Bstrurl: the URL of the Service webpage.
Varasync: whether to run the command synchronously. The default value is true, that is, synchronous execution, but can only be performed in the Dom.
In applications, set it to false, that is, asynchronous execution.
Bstruser: user name, which can be omitted.
Bstrpassword: user password, which can be omitted.
Send varbody
Varbody: instruction set. It can be XML data, a string, a stream, or an unsigned integer array. It can also be omitted, so that the command can be substituted by the URL parameter of the open method.
SetRequestHeader bstrheader, bstrvalue
Bstrheader: HTTP Header)
Bstrvalue: HTTP header value
If the open method is defined as post, you can define form upload:
XMLHTTP. setRequestHeader Content-Type, applicationx-WWW-form-urlencoded
XMLHTTP attributes:
Onreadystatechange: obtains the event handle of the returned result in synchronous execution mode. It can only be called in the Dom.
Responsebody: returns an unsigned integer array.
Responsestream: The returned result is an istream stream.
Responsetext: returns a string.
Responsexml: The returned result is in XML format.
The following is an example of an application in the source program appended to this article:
Function getresult (urlstr)
Dim XMLHTTP
Dim retstr
Set XMLHTTP = Createobject (msxml2.xmlhttp 'creates an object
On Error resume next 'error handling
XMLHTTP. Open post, urlstr, false' use post to open the connection and execute it asynchronously.
XMLHTTP. setRequestHeader Content-Type, applicationx-WWW-form-urlencoded 'upload form
XMLHTTP. Send' send command
If err. Number = 0 then', if the connection is correct
Retstr = XMLHTTP. responsetext 'wait and get the result string returned by the server
Else
Retstr = URL not found '; otherwise, an error message is returned.
End if
Set XMLHTTP = nothing 'release the object
Getresult = retstr 'Return result
End Function
The getresult () function brings the URL parameter of a Service webpage and places the Upload Command on the parameter following the URL, for example:
Urlstr = server. aspcmd = & cmd & DB = & dB & table = & table
CMD: Execution method, such as query, modification, and deletion.
DB: name of the server database
Table: the name of the server table.
Then, submit the command and wait for and receive the returned processing result. The result is returned as a string.
Finally, the function caller processes and displays the result.
The following is the content of the thief:
Filename Tianqi. asp
Write by niaoked qq408611119
Www.knowsky.com
<%
If hour (now) = 9 and minute (now) <30 then
Getcategories ()
End if
Function getcategories ()
On Error resume next
Dim oxmlhttp 'as object
Dim ocategories 'as object
Dim bodytext
Dim POs, pos1
Set oxmlhttp = Createobject ("Microsoft. XMLHTTP ")
'--- Set the XMLHTTP call and issue send (no parm as Category
'--- Is encoded in URL
Oxmlhttp. Open "get", "http://weather.china.com.cn/travel_gntq.php? Cityid = 56196 & cityname = Mianyang ", false' replace this address with your own address.
Oxmlhttp. Send
'--- Load the response into the categories data island
Bodytext = oxmlhttp. responsebody
Bodytext = bytestobstr (bodytext, "gb2312 ")
Pos = instr (bodytext, "<body ")
Pos1 = instr (bodytext, "</body> ")
Bodytext = mid (bodytext, POs, pos1)
Bodytext = Split (bodytext, "<Table ")
Pos = instr (bodytext (4), "<TR ")
Pos1 = instr (bodytext (4), "</tr> ")
Body = mid (bodytext (4), POs, Len (bodytext (4)-Pos)
Body = Split (body, "</table> ")
Body1 = Split (replace (body (0), "<br>", ""), "</TD> ",""), "</tr>", ""), "Weather ")
For I = 1 to ubound (body1)
Body3 = Split (body1 (I), "<TD ")
Weather = weather & "document. Write (" "& I &" $ "&" Weather"
& Htmlencode (TRIM (body3 (0) & ""); "& vbcrlf
Next
Weather = Replace (weather, "1 $", "<font color = # ffffff> [Today] </font> ")
Weather = Replace (weather, "2 $", "<font color = # ffffff> [tomorrow] </font> ")
Weather = Replace (weather, "3 $", "<font color = # ffffff> [day after tomorrow] </font> ")
Set FS = Createobject ("scripting. FileSystemObject ")
Set F = FS. createtextfile (request. servervariables ("appl_physical_path") & "TQ. js", true)
F. Write ("document. Write ('mianyang Weather Forecast: ');" & vbcrlf & replace (weather, "<br> ",""))
F. Close
Set F = nothing
Set FS = nothing
Response. Write "Mianyang Weather Forecast:" & weather
Set oxmlhttp = nothing
If err. Number <> 0 then
Response. Write "error, error Description:" & err. Description & "<br> error source" & err. Source
Response. End ()
End if
End Function
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
Public Function htmlencode (fstring)
If not isnull (fstring) then
Fstring = Replace (fstring, ">", "& gt ;")
Fstring = Replace (fstring, "<", "& lt ;")
Fstring = Replace (fstring, CHR (32), "") '& nbsp;
Fstring = Replace (fstring, CHR (9), "") '& nbsp;
Fstring = Replace (fstring, CHR (34), "& quot ;")
Fstring = Replace (fstring, CHR (39), "'")' single quotation mark Filtering
Fstring = Replace (fstring, CHR (13 ),"")
Fstring = Replace (fstring, CHR (10) & CHR (10), "</P> <p> ")
Fstring = Replace (fstring, CHR (10), "<br> ")
Htmlencode = fstring
End if
End Function
%>