Lisitng the URLs in a Web Page

This demo illustrates how to use regular expressions to display all of the URLs referenced in HREF tags in a Web page. (In this example, URLs are defined as appearing in an HREF tag and starting with http://.) The below list of URLs are those from the start page at

List of URLs in www.ASP.NET

Source Code
  Dim strFileName 
  strFileName = Server.MapPath("/demos/")

  Dim objFSO, objTS, strHTML
  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
  Set objTS = objFSO.OpenTextFile(strFileName)
  strHTML = objTS.ReadAll
  Set objTS = Nothing
  Set objFSO = Nothing

  Dim objRegExp
  Set objRegExp = new RegExp

  objRegExp.IgnoreCase = True
  objRegExp.Global = True
  objRegExp.Pattern = "<a\s+href=""http://(.*?)"">\s*((\n|.)+?)\s*</a>"

  For Each objMatch in objRegExp.Execute(strHTML)
    Response.Write("<li>http://" & objMatch.SubMatches(0) & "<br>")

  Set objRegExp = Nothing

[Return to the Article] | [View the HREF-to-Text Demo]