" />
時間:2023-03-02 01:36:01 | 來源:建站知識
時間:2023-03-02 01:36:01 來源:建站知識
如何提取網(wǎng)頁中和圖片相關的代碼:因為有個朋友急需要這方面的資料,所以我簡單點說:
兩種方法:
1、正則表達式,先把代碼寫出來,我再詳細解釋。
圖片都是寫在里的,所以只要把這個代碼查出來一切就解決了。
<%
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches'建立變量。
Set regEx = New RegExp'建立正則表達式。
regEx.Pattern = patrn'設置模式。
regEx.IgnoreCase = True'設置是否區(qū)分字符大小寫。
regEx.Global = True'設置全局可用性。
Set Matches = regEx.Execute(strng)'執(zhí)行搜索。
For Each Match in Matches'遍歷匹配集合。
RetStr = RetStr & "Match found at position "
RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
RetStr = RetStr & Match.Value & "'." & "<BR>"
Next
RegExpTest = RetStr
End Function
response.write RegExpTest"/<img.*?/>",網(wǎng)頁代碼)
%>
(做個廣告:特價機票)
這段代碼運行的結(jié)果就是提取所有代碼,得到了所有的圖片。
2、split解決。
代碼:
a=網(wǎng)頁內(nèi)容
b=split(a,"
這樣把網(wǎng)頁內(nèi)容以ubound(b)的值是包含圖片的總數(shù)。
下面提取詳細信息。
用個循環(huán)。
for i=1 to ubound(b)
c=split(b(i),">")
c(0)就是圖片相關的信息。
next
詳細代碼到下載。
關鍵詞:相關,圖片,中和,提取
微信公眾號
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。