|
-
Sep 22nd, 2011, 07:40 PM
#1
Thread Starter
Hyperactive Member
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
-
Sep 22nd, 2011, 10:12 PM
#2
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:
For Each iElmnt In iDoc.getElementsByTagName("a") 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|