The thief mentioned here refers to using the powerful functions provided by the xmlhttp component in xml in asp to capture the data (pictures, web pages and other files) on the remote website to the local, and display it on the page after various processing Or a type of program that is stored in a database. You can use this kind of thief program to complete some tasks that seemed completely impossible in the past, such as changing the pages of a certain website and turning them into your own pages, or saving some data (articles, pictures) of a certain website to be used in the local database. The advantages of Thief 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 a lot of 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. How about it, sounds amazing, right? Let’s start learning some introductory knowledge of the thief program now!
Let’s study something simpler, the weather forecast program on the QQ website
The code is as follows:
1<%2OnErrorResumeNext
3Server.Scripttimeout=9999999
4FunctionGethttppage(Path)
5T=Getbody(Path)
6Gethttppage=Bytestobstr(T,Gb2312)
7End Function
8
9' First, make some initialization settings for the thief program. The function of the above code is to ignore all non-fatal errors, set the running timeout of the thief program to a very long time (so that no running timeout error will occur), and convert the original The default utf-8 encoding is converted into gb2312 encoding, otherwise directly using the xmlhttp component to call web pages with Chinese characters will result in garbled codes.
10
11FunctionGetbody(Url)
12OnErrorResumeNext
13SetRetrieval=Createobject(Microsoft.Xmlhttp)
14WithRetrieval
15.OpenGet, Url,False,,
16.Send
17Getbody=.Responsebody
18EndWith
19SetRetrieval=Nothing
20End Function
twenty one
22'Then call the xmlhttp component to create an object and perform initialization settings.
twenty three
24FunctionBytestobstr(Body,Cset)
25DimObjstream
26SetObjstream=Server.Createobject(Adodb.Stream)
27Objstream.Type=1
28Objstream.Mode=3
29Objstream.Open
30Objstream.WriteBody
31Objstream.Position=0
32Objstream.Type=2
33Objstream.Charset=Cset
34Bytestobstr=Objstream.Readtext
35Objstream.Close
36SetObjstream=Nothing
37End Function
38
39FunctionNewstring(Wstr,Strng)
40Newstring=Instr(Lcase(Wstr),Lcase(Strng))
41IfNewstring<=0ThenNewstring=Len(Wstr)
42End Function
43
44' To process the captured data, you need to call the adodb.Stream component and perform initialization settings. %>