Get URL of image source

moberry

New Member
Joined
Mar 22, 2012
Messages
11
Hi. I am trying to pull the URL of a certain image when using the ie.getelementby... method.

Using the following I can access the url I need but it's surrounded by html code that is proving difficult for me to seperate out:

test = ie.document.getElementById("recaptcha_image").InnerHtml

this is what debug.print test shows me:


<IMG style="DISPLAY: block" alt="reCAPTCHA challenge image" src="http://www.google.com/recaptcha/api/image?c=03AHJ_VuseNxC9vqebkGvR3AamjyyeAaPVUSkJcCkZ6fVvhQbxIOC8YiIZHV9p6-Ay-09daLWUf3BSIeYIHqczZVIKAhdFR_HnqTlEMUXNga81zlDAIJ2fwwM9qMEgLxkXM568OSGCvuiQn-QVI6Ob7y1RWKXpMEjIMA" width=300 height=57>

does anyone have any suggestions or a completely different way I should be looking at the image source?


Just for clarity, I'm pulling an image from a site and pasting it into a specified cell. I already have part 2 working but I have to pass in the necessary url. If I paste in the url from getelementbyid (manually extracting it) the correct image shows up in excel.


I don't believe im violating any terms of service regarding captcha as im still requiring a person to type in the response.


thanks in advance!
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
You should be able to use this to pull out the image URL.
Code:
imgURL = Mid(test, InStr(1, test, Chr(34)) + 1, InStr(InStr(1, test, Chr(34)) + 1, test, Chr(34)) - (InStr(1, test, Chr(34)) + 1))

this pulls everything between the first and second quotation mark [Chr(34)].
 
Upvote 0
Use the src attribute/property of the image to get the URL.
Code:
test = ie.document.getElementById("recaptcha_image").src
 
Upvote 0
Use the src attribute/property of the image to get the URL.
Code:
test = ie.document.getElementById("recaptcha_image").src

Nice. I don't use the IE objects very often so if this works it is clearly much simpler.
 
Upvote 0
It'll only work if getElementByID returns an image element, or another type of element that has src as a propert, eg video, audio.
 
Upvote 0
Use the src attribute/property of the image to get the URL.
Code:
test = ie.document.getElementById("recaptcha_image").src

Yeah i tried .src but I get:

"Run-time error '438':

Object doesn't support this property of method"



i dont get the above error with .innerhtml
 
Upvote 0
It'll only work if getElementByID returns an image element, or another type of element that has src as a propert, eg video, audio.

so the problem is that I am using the wrong definition for the "test" variable or is it that if I set the image as an element I won't be able to extract the source url?





I tried messing around with some find and replace type of stuff to grab the url from the test string that I had but its got quotations in it that was screwing things up.


thanks for the help
 
Upvote 0
Does ie.document.getElementById("recaptcha_image") return an image?

What's the entire HTML for the node?

You can post it here if you enclose it in
HTML:
tabs.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top