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 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.
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,224,816
Messages
6,181,138
Members
453,021
Latest member
Justyna P

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