我正試圖在iexapicloud上進行批量請求。以下是我正在使用的檔案。
https://iexcloud.io/docs/api/#batch-requests
為了測驗批處理請求,我使用了一個沙盒api和一些隨機的股票代碼,我一直得到一個json錯誤:
import numpy as np
import pandas as pd
import requests
import json
sandbox_api = 'Tpk_002d9beb3a9c489d98368b78d1ecf00'。
url = f'https://sandbox.iexapis.com/stable/stock/market/batch?symbols=AAPL,FB,TSLA&types=quote?token={sandbox_api}'
data = requests.get(url).json()
JSONDecodeError。額外的資料:第1行第9列-第1行第36列(char 8 - 35)
。
uj5u.com熱心網友回復:
將URL中的最后一個?替換為&:
import requests
sandbox_api = "Tpk_002d9beb3a9c489d98368b78bd1ecf00"/span>
url = f "https://sandbox.iexapis.com/stable/stock/market/batch?symbols=AAPL,FB,TSLA&types=quote&token={sandbox_api}"
data = requests.get(url).json()
print(data)
列印:
{}。
"AAPL": {
"quote": {
"avgTotalVolume": 81528699,
"calculationPrice": "tops",
"change": -3.35,
"changePercent": -0.02349,
"close": 0,
"closeSource": "fcfioali",
"closeTime": None,
"companyName": "Apple Inc",
"貨幣": "USD",
"delayedPrice": None,
"delayedPriceTime": None,
"extendedChange": None,
...
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/322784.html
標籤:
