我正在尝试解析来自股票exhcange网站的数据,例如对于特定股票的URL是
https://nseindia.com/live_market/dynaContent/live_watch/get_quote/GetQuote.jsp?symbol=SGJHL
我需要的数据在id =“responseDiv”(下面提取)下,并包含在子数据“data”中。虽然我可以使用beautifulsoup获取原始数据,但最有效的方法是将其分解为一个键:值字典?
我不能使用“,”因为它打破了包含“,”作为千位分隔符的数值。
非常感谢!
{"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":""}
答案 0 :(得分:0)
这似乎是一个JSON响应。您可以使用JSON库来访问键值,如下所示:
jsonData = json.load('YOUR RAW DATA')
print (jsonData['bcStartDate'])