Using regular and XMLHTTP to realize the ASP Thief program _ Thieves/Collection

Source: Internet
Author: User
Copy Code code as follows:

<%
'========================================
Class Engineersearch
' Lao Long: laolong9999@sina.com
': Simulate XML get HTTP tag resource (know why XML is useful after use:))
' Use the engine search (display engine information or information on its hyper-connected web site or directly on a specific page, using regular and XMLHTTP,
' The use of the program needs to be structured.
'---------------------------------------------------------------
Private Oreg,oxmlhttp ' A regular, a Microsoft XMLHTTP
'---------------------------------------------------------------
Public Sub Class_Initialize () object establishes trigger
Set Oreg=new REGEXP
Oreg.global=true
Oreg.ignorecase=true
Set Oxmlhttp=server.createobject ("Microsoft.XMLHTTP")
End Sub
'---------------------------------------------------------------
Public Sub Class_Terminate () ' Object Destroy Trigger
Set Oreg=nothing ' must manually release the self-built objects within the class, and the ASP will only automatically release objects defined by class
Set oxmlhttp=nothing
If TypeName (Tempreg) <> "Nothing" then "method objects in vivo release resources
Set tempreg=nothing
End If
End Sub
'---------------------------------------------------------------
' Engine-level search
Public Function engineer (URL,ENGINEERREG)
' Function Description: Get the return information of the URL (usually used for engine lookup), extract the specific information of the Engineerreg, and return matches collection to
' Function name. Obtain the URL query result, search out the result with Engineerreg regular definition, generate a matches collection,
' Because it is not possible to set the number of collections and operations (VBScript), it is best to traverse the collection itself, or consider a two-dimensional array
Dim strconent
Strcontent=oxmlhttp.open ("Get", Url,false)
On Error Resume Next
Oxmlhttp.send ()
If Err.number<>0 Then
Exit function
End If
Strcontent=bytes2bstr (Oxmlhttp.responsebody)
If IsNull (Engineerreg) Then
Engineer=absoluteurl (Strcontent,url)
Else
Oreg.pattern=engineerreg
Set Engineer=oreg.execute (Absoluteurl (Strcontent,url))
End If
End Function
'---------------------------------------------------------------
' Encoding, (net person)
Public Function bytes2bstr (vIn)
Strreturn = ""
For i = 1 to LenB (vIn)
Thischarcode = AscB (MidB (vin,i,1))
If Thischarcode < &h80 Then
Strreturn = Strreturn & Chr (Thischarcode)
Else
Nextcharcode = AscB (MidB (vin,i+1,1))
Strreturn = Strreturn & Chr (CLng (thischarcode) * &h100 + CInt (nextcharcode))
i = i + 1
End If
Next
Bytes2bstr = Strreturn
End Function
'---------------------------------------------------------------
Public Function searchreplace (Strcontent,replacereg,resultreg)
' Replace, Replacereg the string described in strcontent with resultreg description of the replacement, return to Searchreplace
' To encapsulate the regular replace.
Oreg.pattern=replacereg
Searchreplace=oreg.replace (Strcontent,resultreg)
End Function
'---------------------------------------------------------------
Public Function absoluteurl (strcontent,byval URL)
' Changes the relative URL in the strcontent to the absolute address of the URL specified in Oxmlhttp (http/https/ftp/mailto:)
' You can modify the changes.
Dim Tempreg
Set Tempreg=new REGEXP
Tempreg.ignorecase=true
Tempreg.global=true
Tempreg.pattern= "(^.*\/). *$" ' Standard path with file name http://www.wrclub.net/default.aspx
Url=tempreg.replace (URL, "$")
Tempreg.pattern= "((?: src|href). *?=[\ ' \u0022] (?! Ftp|http|https|mailto)) "
Absoluteurl=tempreg.replace (Strcontent, "$" +url)
Set tempreg=nothing
End Function
'---------------------------------------------------------------
End Class
'========================================
%>
<% ' Example
Response.Charset = "GB2312"
Dim Mysearch
Set Mysearch=new Engineersearch
' URL must be a complete address containing the file name extension, the result is a collection, each item in the collection is an array, and you should refer to subqueries like this: mymatches (0). submatches (0)
Set Mymatches=mysearch.engineer ("Http://www.wrclub.net/default.aspx", "If Mymatches.count=0 Then
Response.Write "Without your regular string"
End If
If Mymatches.count>0 Then
Response.Write mymatches.count& "<br>"
For each key in Mymatches
Response.Write key.firstindex& ":" &cstr (key.value) & "<br>"
Next
End If
%>

many more applications, as long as you will

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.