Cant get this link from HTML

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
Office Version
  1. 2016
Platform
  1. Windows
I am trying to get this link which is in a heading h2 but can not work it out
1583674490499.png


I though this would do it
VBA Code:
 For Each div In HTMLdoc.getElementsByTagName("li")
                If div.getAttribute("class") = "h2" Then
                    Set link = div.getElementsByTagName("a")(0)
                    .Cells(i, 1).Value = link.getAttribute("href")
                    i = i + 1
                End If

Or this
VBA Code:
  For Each link In HTMLdoc.getElementsByTagName("a")
            If link.getAttribute("li class") = "h2" Then
                Cells(i, 1).Value = link.getAttribute("href")
                i = i + 1
            End If
        Next link

But I can not work it out, can someone take a quick look please

Thanks
 

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.
It okay I have done it.

VBA Code:
   For Each li In HTMLdoc.getElementsByTagName("li")
                If li.getAttribute("class") = "b_algo" Then
                    Set link = li.getElementsByTagName("a")(0)
                    .Cells(i, 1).Value = link.getAttribute("href")
                    i = i + 1
                End If
             
  Next li
 
Upvote 0

Forum statistics

Threads
1,215,644
Messages
6,125,993
Members
449,279
Latest member
Faraz5023

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