-
Notifications
You must be signed in to change notification settings - Fork 1
/
CoinMarketCap.py
47 lines (33 loc) · 900 Bytes
/
CoinMarketCap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import json
import requests
import string
import re
from collections import Counter
def getCoinNames():
""" parses all coins' names and returns them in the form of a list
"""
# file = open("Coins.txt","w")
result = []
r = requests.get('https://api.coinmarketcap.com/v1/ticker/?limit=100')
for coin in r.json():
strong = str(coin)
strong = coin["name"].lower() # encode('ascii','ignore')
# removes spaces in a coin's name
strong = re.sub('[\s+]', '', strong)
result.append(strong)
return result
file .close()
def getCoinSymbols():
""" parses all coins' symbols and returns them in the form of a list
"""
result = []
r = requests.get('https://api.coinmarketcap.com/v1/ticker/?limit=100')
for coin in r.json():
strong = str(coin)
strong = coin["symbol"].lower()
result.append(strong)
return result
def main():
getCoins()
if __name__ == '__main__':
main()