我正在使用以下代碼:
import requests
from requests.structures import CaseInsensitiveDict
url='https://public-api.solscan.io/account/transactions?account=24jvtWN7qCf5GQ5MaE7V2R4SUgtRxND1w7hyvYa2PXG6'
headers = CaseInsensitiveDict()
headers["accept"] = "application/json"
resp = requests.get(url, headers=headers)
print(resp.json())
我收到一個錯誤:JSONDecodeError: Expecting value: line 1 column 1 (char 0)
我希望以以下形式獲得輸出,key:value然后將其轉換為 DataFrame。為什么會出現我的錯誤?
uj5u.com熱心網友回復:
使用headers實際作業。
試試這個:
import requests
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36'
}
url = 'https://public-api.solscan.io/account/transactions?account=24jvtWN7qCf5GQ5MaE7V2R4SUgtRxND1w7hyvYa2PXG6'
resp = requests.get(url, headers=headers)
print(resp.json()[0]['signer'])
樣本輸出:
['7BjLjdJEGLaLscYkpw57YKzYqRY1i3ypnfLK8R2bgDrC', '7qfzWZmyYU1PBYJG5Y2ksSbaf6xHc77Tx47urzySFins']
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/465606.html
下一篇:在Python中向條形圖添加虛線
