mirror of
https://github.com/jwinterm/py-ticker.git
synced 2026-10-17 05:41:39 +02:00
19 lines
479 B
Python
19 lines
479 B
Python
import requests
|
|
|
|
cmcurl = 'https://api.coinmarketcap.com/v1/ticker?limit=10'
|
|
|
|
def getcmc():
|
|
ticker_string = ''
|
|
try:
|
|
r = requests.get('https://api.coinmarketcap.com/v1/ticker?limit=10')
|
|
j = r.json()
|
|
with open('cachedCMC.txt', 'w') as f:
|
|
f.write(r.text)
|
|
except:
|
|
print("Failed to get CMC via API")
|
|
with open('cachedCMC.txt', 'r') as f:
|
|
j = f.read().json()
|
|
# for i in j:
|
|
# print(i)
|
|
return j
|