ASP gets the full picture address of the Web page and saves it to the array.

Source: Internet
Author: User
Page | array | image address 1.31 correction
There are spaces behind the src= that do not match correctly. Modified.
Error src= ' is empty. Modified.
Bug found: A picture path can have more than one space. Not fixed.
2.18 Amendment
A picture path can have more than one space in it. has been fixed.


Here's the code:
<%
' Function: Get all picture addresses, save to an array.
' Source: http://jorkin.reallydo.com/article.asp?id=448
' Need ReplaceAll function: http://jorkin.reallydo.com/article.asp?id=406

Function getimg (sstring)
Dim Sreallydo, RegEx, Ireallydo
Dim Omatches, Cmatch
'//define an empty array
Ireallydo =-1
ReDim Areallydo (Ireallydo)
If IsNull (sstring) Then
Getimg = ""
Exit Function
End If
'//Format HTML code
'//Sreallydo = sstring
On Error Resume Next
Sreallydo = Replace (Sreallydo, vbcr, "")
Sreallydo = Replace (Sreallydo, vblf, "")
Sreallydo = Replace (Sreallydo, VbTab, "")
Sreallydo = Replace (Sreallydo, "Sreallydo = Replace (Sreallydo, "/>", "/>", 1,-1, 1)
Sreallydo = ReplaceAll (Sreallydo, "=", "=", True)
Sreallydo = ReplaceAll (Sreallydo, ">", ">", True)
Sreallydo = Replace (Sreallydo, "><", ">" & vbCrLf & "<")
Sreallydo = Trim (Sreallydo)
On Error GoTo 0
Set regEx = New RegExp
Regex.ignorecase = True
Regex.global = True
'//Remove scripts such as Onclick,onload
Regex.pattern = "\s[on].+?= ([\" "|\ '])" (. *?) \1 "
Sreallydo = Regex.Replace (Sreallydo, "")
'//Add quotation marks to the picture address of SRC without quotes
Regex.pattern = "]*) .*?>"
Sreallydo = Regex.Replace (Sreallydo, "'//Regular matching picture src address
Regex.pattern = " "
Set omatches = Regex.execute (Sreallydo)
'//Save picture address in array
For each cmatch in omatches
Ireallydo = Ireallydo + 1
ReDim Preserve Areallydo (Ireallydo)
Areallydo (Ireallydo) = Regex.Replace (Cmatch.value, "$")
Next
Getimg = Areallydo
End Function
%>


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.