Can anyone please suggest how to import '500112' and 'SBIN' from https://www.moneycontrol.com/india/stockpricequote/banks-public-sector/statebankindia/SBI in Google spreadsheet using importData or importXML functions?
2
votes
1 Answers
1
votes
Try using
=IMPORTXML(A1,"//ctag[@class='mob-hide']//span") #where A1 is the url
this should get you both.
adding, for example:
=IMPORTXML(A1,"//ctag[@class='mob-hide']//span[1]")
at the end should output just
500112
Edit:
Since the question was asked, the site started using dynamically loaded data which GS can't handle. Using the tools in your browser's Developer tab, you can find out that the target data is loaded from a different site (see below) and that it is in json format.
So you need to use GS's importJSON()
function for that:
A1 = https://priceapi.moneycontrol.com/pricefeed/bse/equitycash/SBI
A2 =importJSON(A1)
Make sure there's enough space on the sheet to expand the output. Once you do, you'll find the two target items under the columns Data Bseid
and Data Nseid
, probably in columns AL and AM.