-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
47 lines (34 loc) · 918 Bytes
/
main.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
from time import sleep
from pushbullet import Pushbullet
import requests
PUSH_API = "Your PushBullet API KEY goes here"
ETH_API = "Your Etherscan API KEY goes here"
URL = "https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=ETH_API"
interval = 1
gas_limit = 75
def get_data():
global gas
try:
response = requests.get(URL)
data = response.json()
gas = float(data['result']['SafeGasPrice'])
except:
print('Error')
sleep(1)
def compare():
global gas
try:
if gas <= gas_limit:
gas = str(gas)
notify = "Current gas price is "
notify = notify + gas
print(notify)
pb = Pushbullet(PUSH_API)
push = pb.push_note('Gas Price Changed', notify)
except:
print('Error.')
sleep(1)
while True:
get_data()
compare()
sleep(interval)