0

I'm trying to parse data from a stock exhcange website and for example for a particular stock the URL is

https://nseindia.com/live_market/dynaContent/live_watch/get_quote/GetQuote.jsp?symbol=SGJHL

and the data I need is under id="responseDiv" (extracted below) and is contained within the subarray "data". While I can get the raw data using beautifulsoup, what is the most efficient way to break this into a key:value dictionary?

I can't use "," since it breaks on numerical values which contain "," as thousand separators.

Many thanks!

{"futLink":"","otherSeries":["EQ"],"lastUpdateTime":"26-AUG-2016 16:00:00","tradedDate":"26AUG2016",**"data":[{"extremeLossMargin":"5.00","cm_ffm":"11.65","bcStartDate":"18-SEP-15","change":"-","buyQuantity3":"-","sellPrice1":"-","buyQuantity4":"-","sellPrice2":"-","priceBand":"20","buyQuantity1":"-","deliveryQuantity":"42,643","buyQuantity2":"-","sellPrice5":"-","quantityTraded":"51,997","buyQuantity5":"-","sellPrice3":"-","sellPrice4":"-","open":"6.00","low52":"5.80","securityVar":"6.41","marketType":"N","pricebandupper":"7.20","totalTradedValue":"3.13","faceValue":"10.00","ndStartDate":"-","previousClose":"6.00","symbol":"SGJHL","varMargin":"25.98","lastPrice":"6.00","pChange":"0.00","adhocMargin":"-","companyName":"SHREE GANESH JEWELLERY HOUSE (I) LIMITED","averagePrice":"6.02","secDate":"26AUG2016","series":"EQ","isinCode":"INE553K01019","indexVar":"15.00","pricebandlower":"4.80","totalBuyQuantity":"-","high52":"13.00","purpose":"ANNUAL GENERAL MEETING","cm_adj_low_dt":"19-AUG-16","closePrice":"6.00","isExDateFlag":false,"recordDate":"-","cm_adj_high_dt":"16-OCT-15","totalSellQuantity":"-","dayHigh":"6.15","exDate":"15-SEP-15","sellQuantity5":"-","bcEndDate":"24-SEP-15","css_status_desc":"Listed","ndEndDate":"-","sellQuantity2":"-","sellQuantity1":"-","buyPrice1":"-","sellQuantity4":"-","buyPrice2":"-","sellQuantity3":"-","applicableMargin":"30.98","buyPrice4":"-","buyPrice3":"-","buyPrice5":"-","dayLow":"5.90","deliveryToTradedQuantity":"82.01","totalTradedVolume":"51,997"}]**,"optLink":""}
Ozgur Vatansever
  • 49,246
  • 17
  • 84
  • 119
oscar
  • 11
  • 1

1 Answers1

0

It seems that this is a JSON response. You can use JSON library to access to the key values like this :

jsonData = json.load('YOUR RAW DATA')
print (jsonData['bcStartDate'])
Reza Tanzifi
  • 572
  • 4
  • 13