-
Notifications
You must be signed in to change notification settings - Fork 0
/
priceAPI.py
83 lines (75 loc) · 2.64 KB
/
priceAPI.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from requests import get as rget
from flask import Flask
from bs4 import BeautifulSoup as bs
app = Flask(__name__)
@app.route("/")
def index():
return """
/btc for current price of bitcoin
<br>
/celo for current price of celo
<br>
/tsla for current price of tokenized tesla stonk
<br>
/eth for current price of ethereum
<br>
/euro for current price of euro coin
<br>
/sona for current price of tether gold
"""
@app.route('/sona')
def sona():
url = "https://coinmarketcap.com/currencies/tether-gold/"
response = rget(url)
content = response.content
soup = bs(content,'lxml')
divPrice = soup.find_all('div',class_ = "priceValue")
currentPrice = divPrice[0].find('span').text.replace("$","").replace(",","")
return currentPrice
@app.route('/celo')
def celo():
url = "https://coinmarketcap.com/currencies/celo/"
response = rget(url)
content = response.content
soup = bs(content,'lxml')
divPrice = soup.find_all('div',class_ = "priceValue")
currentPrice = divPrice[0].find('span').text.replace("$","").replace(",","")
return currentPrice
@app.route('/tsla')
def tsla():
url = "https://coinmarketcap.com/currencies/tesla-tokenized-stock-bittrex/"
response = rget(url)
content = response.content
soup = bs(content,'lxml')
divPrice = soup.find_all('div',class_ = "priceValue")
currentPrice = divPrice[0].find('span').text.replace("$","").replace(",","")
return currentPrice
@app.route('/eth')
def eth():
url = "https://coinmarketcap.com/currencies/ethereum/"
response = rget(url)
content = response.content
soup = bs(content,'lxml')
divPrice = soup.find_all('div',class_ = "priceValue")
currentPrice = divPrice[0].find('span').text.replace("$","").replace(",","")
return currentPrice
@app.route('/euro')
def euro():
url = "https://coinmarketcap.com/currencies/euro-coin/"
response = rget(url)
content = response.content
soup = bs(content,'lxml')
divPrice = soup.find_all('div',class_ = "priceValue")
currentPrice = divPrice[0].find('span').text.replace("$","").replace(",","")
return currentPrice
@app.route('/btc')
def btc():
url = "https://coinmarketcap.com/currencies/bitcoin/"
response = rget(url)
content = response.content
soup = bs(content,'lxml')
divPrice = soup.find_all('div',class_ = "priceValue")
currentPrice = divPrice[0].find('span').text.replace("$","").replace(",","")
return currentPrice
if __name__ == '__main__':
app.run('127.0.0.1',8004,debug=False)