2,619
次編輯
Tankianting(討論 | 貢獻) |
Tankianting(討論 | 貢獻) |
||
行 27: | 行 27: | ||
<pre>curl "https://query1.finance.yahoo.com/v8/finance/chart/2330.TW?metrics=Date,High,Low,Open,Close,Volume&interval=1d&range=3d" > a.txt</pre> | <pre>curl "https://query1.finance.yahoo.com/v8/finance/chart/2330.TW?metrics=Date,High,Low,Open,Close,Volume&interval=1d&range=3d" > a.txt</pre> | ||
輸出結果: | |||
<pre> | |||
{"chart":{"result":[{"meta":{"currency":"TWD","symbol":"2330.TW","exchangeName":"TAI","instrumentType":"EQUITY","firstTradeDate":946947600,"regularMarketTime":1688707805,"gmtoffset":28800,"timezone":"CST","exchangeTimezoneName":"Asia/Taipei","regularMarketPrice":565.0,"chartPreviousClose":582.0,"priceHint":2,"currentTradingPeriod":{"pre":{"timezone":"CST","start":1688691600,"end":1688691600,"gmtoffset":28800},"regular":{"timezone":"CST","start":1688691600,"end":1688707800,"gmtoffset":28800},"post":{"timezone":"CST","start":1688707800,"end":1688707800,"gmtoffset":28800}},"dataGranularity":"1d","range":"3d","validRanges":["1d","5d","1mo","3mo","6mo","1y","2y","5y","10y","ytd","max"]},"timestamp":[1688518800,1688605200,1688691600],"indicators":{"quote":[{"low":[579.0,565.0,563.0],"close":[582.0,565.0,565.0],"open":[589.0,573.0,565.0],"high":[589.0,574.0,572.0],"volume":[14913592,28564891,18796190]}],"adjclose":[{"adjclose":[582.0,565.0,565.0]}]}}],"error":null}} | |||
</pre> | |||
我們需要排整齊,以利閱讀,使用 js-beautify排齊,輸出到a_tidy.txt: | |||
<pre>js-beautify a.txt > a_tidy.txt</pre> | |||
結果: | |||
<pre> | |||
{ | |||
"chart": { | |||
"result": [{ | |||
"meta": { | |||
"currency": "TWD", | |||
"symbol": "2330.TW", | |||
"exchangeName": "TAI", | |||
"instrumentType": "EQUITY", | |||
"firstTradeDate": 946947600, | |||
"regularMarketTime": 1688707805, | |||
"gmtoffset": 28800, | |||
"timezone": "CST", | |||
"exchangeTimezoneName": "Asia/Taipei", | |||
"regularMarketPrice": 565.0, | |||
"chartPreviousClose": 582.0, | |||
"priceHint": 2, | |||
"currentTradingPeriod": { | |||
"pre": { | |||
"timezone": "CST", | |||
"start": 1688691600, | |||
"end": 1688691600, | |||
"gmtoffset": 28800 | |||
}, | |||
"regular": { | |||
"timezone": "CST", | |||
"start": 1688691600, | |||
"end": 1688707800, | |||
"gmtoffset": 28800 | |||
}, | |||
"post": { | |||
"timezone": "CST", | |||
"start": 1688707800, | |||
"end": 1688707800, | |||
"gmtoffset": 28800 | |||
} | |||
}, | |||
"dataGranularity": "1d", | |||
"range": "3d", | |||
"validRanges": ["1d", "5d", "1mo", "3mo", "6mo", "1y", "2y", "5y", "10y", "ytd", "max"] | |||
}, | |||
"timestamp": [1688518800, 1688605200, 1688691600], | |||
"indicators": { | |||
"quote": [{ | |||
"low": [579.0, 565.0, 563.0], | |||
"close": [582.0, 565.0, 565.0], | |||
"open": [589.0, 573.0, 565.0], | |||
"high": [589.0, 574.0, 572.0], | |||
"volume": [14913592, 28564891, 18796190] | |||
}], | |||
"adjclose": [{ | |||
"adjclose": [582.0, 565.0, 565.0] | |||
}] | |||
} | |||
}], | |||
"error": null | |||
} | |||
}</pre> | |||
[[分類:資訊]] | [[分類:資訊]] |