-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.py
54 lines (43 loc) · 1.17 KB
/
example.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
import time
import os
import json
import requests
from bs4 import BeautifulSoup
import csv
import sys
from time import sleep
from time import gmtime, strftime
import matplotlib.pyplot as plt
enddate = strftime("%Y%m%d", gmtime())
r = requests.get("https://coinmarketcap.com/currencies/eos/historical-data/?start=20140101&end={0}".format(enddate))
data = r.text
soup = BeautifulSoup(data, "html.parser")
table = soup.find('table', attrs={ "class" : "table"})
prices = []
for row in table.find_all('tr'):
addPrice = False
tag = row.findAll('td')
for val in tag:
value = val.text
if "Sep 10" in value:
print(value)
addPrice = True
if addPrice == True:
prices.append( tag[3].text )
# flip list, months are in reverse order
prices = prices[::-1]
for i in range(0,len(prices)):
prices[i] = float(prices[i])
#for price in prices:
# price = float(price)
print(prices)
x = list(range(0, len(prices)))
print(x)
x = list(range(0, len(prices)))
plt.title('eos price from 2014')
plt.ylabel('Price in USD')
plt.xlabel('Years from 2014')
plt.bar(x, prices)
os.system("rm -rf chart.png")
time.sleep(1)
plt.savefig('chart.png')