Get Page Images Code Example

The following example demonstrates using the WebPage object to retrieve all images on a web page.


Private Sub Command4_Click()
    GetImages ""
End Sub

Private Sub GetImages(ByVal url As String)
    'Get the page.
    Web1.Request.url = url

    'Set the web page source.
    Dim WebPage1 As New WebPage
    WebPage1.Source = Web1.response.Body.ReadString

    'Get and list images.
    Dim result As Boolean
    WebPage1.UrlHost = Web1.Request.url
    For i = 1 To WebPage1.Resources.Count
        If WebPage1.Resources.Item(i).UrlType = resImg Then
            result = WebPage1.Resources(i).Get(App.Path + "\images"True, 10000)
            If result = True Then
                listImages.AddItem WebPage1.Resources(i).UrlName
            End If
        End If
End Sub