Extract a href from html

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,066
Office Version
  1. 2016
Platform
  1. Windows
I need to extract href from some html, how do i do this?

this is the href= 'http://www.loungelizard.com

I have html below

HTML:
<div class='c'></div>



		<div class='fl' style='width: 50%;'><a href='/'><img  alt='Design Firm' class='fl' style='border: 0px; margin: 12px 0px 27px 20px;' src='/images/designfirms-logo-blue.png' /></a></div>



		<div class='fl' style='width: 50%; margin-top: 20px;'>



		<div class='fr'><a *******="insert_click('banner', '457')" rel='nw' href='http://www.loungelizard.com'><img alt="" style='border: 1px solid #CCCCCC;' src='/images/advertisers/457.jpg' /></a></div>



		</div>



		<div class='c'></div>


Thanks
 
Last edited:

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
This code see to work in extracting the item from class. The problem is it is not extracting the right class. My html is limited as is my VBA so I can't do much.


Code:
Private Sub CommandButton3_Click()

 Dim http As New XMLHTTP60, html As New HTMLDocument
   Dim source As Object

    With http
       .Open "GET", "http://www.designfirms.org/company/11829/liberty-grove-graphics-llc/", False
        .send
        html.body.innerHTML = .responseText
   End With
    For Each source In html.getElementsByClassName("fr")
       x = x + 1: Cells(x, 1) = source.getAttribute("href")
        Cells(x, 2) = source.getAttribute("")
    Next source
   
End Sub

As far as I understand the class is "fr"
HTML:
<div class='fr'><a *******="insert_click('banner', '1652')" rel='nw' href='http://www.freelancer.com/affiliates/designfirms/'


However it extracts this

/images/icon-social.png

from this

HTML:
<img alt="We're Social!" class='fr' src='/images/icon-social.png' style='border: 0px;' usemap='#social'>

Thanks for having a look
 
Last edited by a moderator:
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,119
Members
452,381
Latest member
Nova88

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