<% '================================================= Class Engineersearch' Old Dragon: Laolong9999 @ sina.com ': Analog XML Gets HTTP tag resources (you know why XML useful after use :))' Use the engine search (display engine information, or the information on its superconnection website, or direct a specified page related information, Regular and xmlhttp, 'program needs to construct regular)' ------------------------------------ --------------------------- private oreg, oxmlhttp 'a regular, a Microsoft XMLHTTP' ----------- -------------------------------------------------- --Public sub class_initialize () 'object established trigger set oreg = new regexporeg.global = trueg.ignorecase = truereoreg.Ignorecase = trueSet oxmlhttp = server.createObject ("Microsoft.xmlhttp") End Sub' ----------- -------------------------------------------------- --Public sub class_terminate () object Destruction Trigger SET OREG = Nothing 'must manually release the self-built object in the class, the ASP only automatically releases objects defined by class OXMLHTTP = Nothingif Typename (Tempreg) <> "Nothing" TEN' Methods of objects in vivo SET TEMPREG = Nothing IFEND SUB '------------------------------------- -------------------------- 'Engine Level Search Public Function Engineer (URL, EngineerReg) function introduction: Get return information for URLs (usually used For the engine lookup), extract the specific information of the ENGINEERREG, return to the Matches collection to the 'function name.
Get the result of the URL query, search for the result of the regular definition of EngineerReg, generate a matches collection, 'Due to the unable to establish a collection and operation set number (VBScript), it is best to traverse the collection, or consider the two-dimensional array DIM STRCONENTSTRCONTENT = OXMLHTTP .open ( "get", url, false) on error resume nextoXmlHttp.send () if err.number <> 0 thenexit functionend ifstrContent = bytes2BSTR (oXmlHttp.responseBody) if isnull (EngineerReg) thenengineer = AbsoluteURL (strContent, url) elseoReg .Pattern = engineerreg set engineer = oreg.execute (absoluteurl (strconteurl (strcontent, url)) end fD function '----------------------------- ---------------------------------- 'Chinese characters code, (net people) public function bytes2bstr (VIN) STRETURN = "" For i = 1 to lenb (vin) thischarcode = ASCB (MIDB (Vin, I, 1)) ife = strreturn & chr (thischarcode) else nextcharcode = ASCB (MIDB (VIN, I 1, 1) Strreturn = Strreturn & Chr (thischarcode) * & H100 CINT (Nextcharcode)) i = i 1 end if next bytes2bstr = strreturn end function '--------------- ------------------------------------------------ Public Function SearchReplace (strcontent, replacereg, resultG) 'replaces, the r in strContent EPLACEREG description The string is used to replace the RESULTREG, and return to the searchReplace to encapsulate the regular replace. Oreg.pattern = replaceregsearchReplace = Oreg.Replace (strcontent, resultreg) end function '--------------------------------- ----------------------------------------------------------------------------------------------------------- The absolute address of the specified URL (http / https / ftp / way :) 'may modify the modification.
DIM TempregSet Tempreg = new regexptempreg.ignorecase = trueTempreg.global = trueTempreg.pattern = "(^. * //). * $" '"with the standard path with the file name http://www.wrclub.net/default.aspxurl= Tempreg.Replace (URL, "$ 1") Tempreg.pattern = "((?: src | href). *? = [/ '/ u0022] (?! ftp | http | https | mailto)" AbsoluteURL = Tempreg. Replace (StrContent, $ 1 " URL) set tempreg = nothingend function '-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----------------------------- End class' ================== ======================%> <% 'example response.charset = "GB2312" DIM Mysearch set mysearch = new engineersErsearch'url must be included in the file extension The complete address, the result is a collection, each item in the collection is an array, which should be referred to: mymatches (0) .submatches (0) set mymatches = mysearch.Engineer ("http://www.wrclub.net/ Default.aspx ","
"for Each key in mymatchesresponse.write key.firstindex & ":" & cstr (key.value) & "
" Nextend if%>
more applications, as long as you will regular b>