Find image link in Javascript and click on it

WebScraper

New Member
Joined
Aug 21, 2017
Messages
4
Hello,

I've found a webpage with some investment products that I would like to export to Excel with some help from VBA. On the webpage there is a small image on the left-side bottom of the page and when I hoover it, it says 'Export table to spreadsheet'. I've tried to 'Inspect element' in order to find an ID or tagname of the image but with no luck :( Further on there is a dropdown next to it that I would like to give the value=6 so I get all products in one single file.

What I would like to do is
  • Call the URL
  • Set the dropdown, 'Select the number of pages...' to 6
  • Click on the image 'Export table to spreadsheet'

My code - so far - looks like this:

Code:
Sub getTuringData()
Dim IE As New InternetExplorer, Url as String
Dim HtmlDoc As New MSHTML.HTMLDocument
Dim ElementCol As Object, Link As Object

Url="[url=http://turing.ngm.se/MDWebFront/quotes.html?underlying=OMXS30&instrumentType=MiniFuture&putCall=CALL&activeTab=ndxQuotes&******]MDWeb Quotes[/url]"
With IE
    .navigate Url
    .Visible = True
    Do While .Busy Or .READYSTATE <> READYSTATE_COMPLETE
        DoEvents
    Loop
    Set HtmlDoc = .document
End With

Application.Wait (Now + TimeValue("00:00:01")) 'Wait so the page loads all Javascript
Set ElementCol = HtmlDoc.getElementsByTagName("img")

For Each Link In ElementCol
    Link.Click
Next

IE.Quit
End Sub

Eventhough it finds all links embedded to images my code doesn't click on the one I would like it to (at least how I see it when I debug it).

Anyone who can help me find the righ image I should click on and a method so I can set the dropdown value before I click?

Thank in advance :)
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,216,089
Messages
6,128,750
Members
449,466
Latest member
Peter Juhnke

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