There are many popular thief programs on the Internet now, including news thief, music thief, and download thief. So how do they do it? Let me give a brief introduction. I hope it will be helpful to all webmasters.
(1) Principle
The thief program actually calls web pages on other websites through the XMLHTTP component in XML. For example, many of the news thief programs call Sina's news web pages, and make some replacements for the HTML in them, and also filter advertisements. The advantages of using the Thief program are: there is no need to maintain the website, because the data in the Thief program comes from other websites, and it will be updated as the website is updated; it can save server resources. Generally, the Thief program only has a few files, and all web content is from other websites. The disadvantages are: instability, if the target website goes wrong, the program will also go wrong, and if the target website is upgraded and maintained, the thief program will also need to be modified accordingly; speed, because it is a remote call, the speed is as fast as reading data on the local server It's definitely slower than that.
(2) Examples
The following is a brief explanation of the application of XMLHTTP in ASP
<%
'Common functions
' 1. Enter the url target web page address, and the return value getHTTPPage is the html code of the target web page.
function getHTTPage(url)
dimHttp
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. Convert Ranma. Directly use xmlhttp to call web pages with Chinese characters. What you get will be Ranma. You can convert it 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 call the html content of http://www.3doing.com/earticle/
Dim Url,Html
Url=" http://www.3doing.com/earticle/ "
Html = getHTTPPage(Url)
Response.write Html
%>