Results 1 to 2 of 2

Thread: how to get image from html

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    Austin
    Posts
    397

    how to get image from html

    trying to find a way to loop on a web page and grab an image.

    <a href="http://www.taco.com/url/http://sharepointed.com/folder/src/blah.png" target="_blank">

    gets a little more tricky, because i need to grab a url from the href.


    Code:
    Dim objIE As Object
    Dim iDoc As HTMLDocument
    Dim iElmnt As IHTMLElement
    Dim strURL As String
    Dim strHTML As String
    
    strURL = "http://sharepointed.com"
    
    Set objIE = CreateObject("InternetExplorer.Application")
    
    With objIE
    .navigate strURL
    .Visible = True
    End With
    
    Do: Loop Until objIE.ReadyState = READYSTATE_COMPLETE
    
    Set iDoc = objIE.Document
    
    For Each iElmnt In iDoc.getElementsByTagName("a href")
    strHTML = iElmnt.outerHTML
    If InStr(1, strHTML, "http://sharepointed.com/folder/src/") > 0 Then
    x = 1
    End If
    Next

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: how to get image from html

    For Each iElmnt In iDoc.getElementsByTagName("a href")
    i do not believe this is correct, try
    vb Code:
    1. For Each iElmnt In iDoc.getElementsByTagName("a")
    2. if instr(iElmnt.href.value, "http://sharepointed.com/folder/src/") > 0 then ' download

    try using urldownloadtofile APIn search here and vb6 forum

    use ielmnt.href.value as the url to download, and a valid path\filename to save to
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width