Wednesday, January 2, 2008

VB6 - Private Function GetHrefs(url As String) As String()

Private Function GetHrefs(url As String) As String()
r.SetExpression ("(?<=href\s*=\s*[""']).*?(?=[""'])")

Private Function GetHrefs(url As String) As String()
'
' Download the source page
'
Dim wc As WebClientWrapper
Set wc = New WebClientWrapper
Dim file As String
file = wc.DownloadFileAsString(url)

'
' Use a regular expression to extract the hrefs from
' the page.
'
Dim r As RegexWrapper
Set r = New RegexWrapper
r.SetIgnoreCase
r.SetExpression ("(?<=href\s*=\s*[""']).*?(?=[""'])")
GetHrefs = r.Matches(file)
End Function