VBA to pull data from HTML Page

grcshekar

New Member
Joined
Dec 11, 2019
Messages
19
Office Version
  1. 2010
Platform
  1. Windows
Hi from the URL GHCL Share Price, GHCL, Live NSE/BSE, Stock Price Today, and Target, Latest News and Analysis I am trying to extract data value of 521.00 under NSE on right hand side.

This code does not seem to work
VBA Code:
Sub FindTickerPrice()        ' Current Market Price of the Selected Ticker ( Share )
    Set Web_browser = New InternetExplorer
    Web_browser.Visible = False
    Web_browser.navigate ("https://www.equitypandit.com/share-price/GHCL")
    Application.Wait (Now + TimeValue("00:00:03"))
    Do While Web_browser.Busy
        DoEvents
    Loop
    Set Web_page = Web_browser.document
    Set qts = Web_page.getElementsByClassName("d-sm-flex align-items-center")(0)
    Debug.Print qts.getElementsByTagName("span")(0).innerText
    SharePrice = qts.getElementsByTagName("span")(0).innerText
    range_pred.Cells(i).Value = SharePrice
    Web_browser.Quit
End Sub        ' Current Market Price of the Selected Ticker ( Share )
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Its working fine now with this code
VBA Code:
Sub FindTickerPrice(ByVal Ticker As String)        ' Current Market Price of the Selected Ticker ( Share )
    Set Web_browser = New InternetExplorer
    Web_browser.Visible = False
    Web_browser.navigate ("https://www.equitypandit.com/share-price/" & Trim(Ticker))
    Application.Wait (Now + TimeValue("00:00:03"))
    Do While Web_browser.Busy
        DoEvents
    Loop
    Set Web_page = Web_browser.document
    
    Set qts = Web_page.getElementById("NSE_PRICE")
    Debug.Print qts.innerText
    SharePrice = qts.getElementsByTagName("span")(0).innerText
    range_pred.Cells(i).Value = SharePrice
    Web_browser.Quit
End Sub        ' Current Market Price of the Selected Ticker ( Share )
 
Upvote 0

Forum statistics

Threads
1,223,705
Messages
6,173,994
Members
452,542
Latest member
Bricklin

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