How to write ASP storage thief procedures _ thieves/collection
Source: Internet
Author: User
Now online more popular thief program, there are news thieves, music thieves, download thieves, then they are how to do it, I would like to do a simple introduction, I hope to help you webmaster.
(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
Code: <%
' 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.998w.net/class/HTML content below
Dim url,html
Url= "http://www.998w.net/class/"
Html = Gethttppage (URL)
Response.Write Html
%>
------------------------------------------------------
Code:
' Code reads remote files with 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=mitchell-pres.zip"
' Specify the content type to tell the browser what:
Response.ContentType = "Application/zip"
' BinaryWrite the bytes to the browser
Response.BinaryWrite Xml.responsebody
Set xml = Nothing
%>
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