Vba code to get data from span class.

shishodia

New Member
Joined
Sep 25, 2015
Messages
7
Hi All,

I have searched for several hours with no luck. What I would like to do is this: I have a vba code with the help of this code I want to get data from span class.

My HTML code

HTML:
<div class="mw_tabContent" style="overflow: hidden; height: 49px; margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; display: block;">         <ul class="mw_contentList highLgt" id="highlightContent">  <li id="Highlights1" category="Banks" style="background-color: rgb(244, 243, 238); color: rgb(51, 51, 51);" class="act_Highl"> <i class="mw_listIcon mw_iconsprite webIconRedBanks"></i>  <span class="mw_content" title="State Bank Of India">State Bank Of India</span>   <span class="mw_units">15 min|4.9 km</span>  </li> </ul>

My vba code

Code:
Sub GoToWebSiteAndPlayAround()
Dim IE As New InternetExplorer
IE.navigate "my url"
IE.Visible = False
Do
DoEvents
Loop Until IE.readyState = READYSTATE_COMPLETE
Application.Wait (Now() + TimeValue("00:00:02"))
Dim doc As HTMLDocument
Set doc = IE.document
Dim dd As Variant
dd = doc.getElementsByClassName("mw_content")(0).innerText
Sheets("Sheet1").Range("A2").Value = dd
IE.Quit
End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Forum statistics

Threads
1,215,403
Messages
6,124,714
Members
449,182
Latest member
mrlanc20

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