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
The thief program actually calls webpages on other websites through the XMLHTTP component in XML. For example, many of the news thief programs call sina's news pages, replace the html and filter advertisements. 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 server resources, generally, a thief program has several files, and all the 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, the thief program must be modified accordingly; speed, because it is a remote call, it 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.
Code: <%
'Common Functions
1. Enter the url of the target webpage. The returned value getHTTPPage is the html code of the target webpage.
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. If you use xmlhttp to call a webpage with Chinese characters, you can use the adodb. stream component to convert the webpage.
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
'Next, try to call the HTML content of http://www.998w.net/class/
Dim Url, Html
Url = "http://www.998w.net/class"
Html = getHTTPPage (Url)
Response. write Html
%>
------------------------------------------------------
Code:
'The Code reads remote files using XMLHTTP
<%
Response. Buffer = True
Dim objXMLHTTP, xml
Set xml = Server. CreateObject ("Microsoft. XMLHTTP"
Xml. Open "GET", "http://www.998w.net/down/998w1.0.rar", False
Xml. Send
'Add a header to give it a file name:
Response. AddHeader "Content-Disposition ",_
"Attachment?filename=*ell-pres.zip"
'Specify the content type to tell the browser what to do:
Response. ContentType = "application/zip"
'Binarywrite the bytes to the browser
Response. BinaryWrite xml. responseBody
Set xml = Nothing
%>