Repository navigation
Expand file tree
/
Copy pathEtherMonitor.py
More file actions
46 lines (39 loc) · 1.87 KB
/
Copy pathEtherMonitor.py
File metadata and controls
46 lines (39 loc) · 1.87 KB
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
import urllib.request as ur
import re
import time
import smtplib
count = 0
response = ur.urlopen( "https://coinmarketcap.com/currencies/ethereum/")
html = response.read()
regex = '<span class="text-large" id="quote_price">(.+?)</span>'
pattern = re.compile(regex)
price =re.findall(pattern, html.decode('utf-8'))
lastHourPrice = float(price[0][1:])
while(True):
response = ur.urlopen( "https://coinmarketcap.com/currencies/ethereum/")
html = response.read()
regex = '<span class="text-large" id="quote_price">(.+?)</span>'
pattern = re.compile(regex)
price =re.findall(pattern, html.decode('utf-8'))
priceNum = float(price[0][1:])
test = ""
#if the price of ether decreases by a min of 10% in the last hour, send text
if priceNum < lastHourPrice:
if (1.0 - (priceNum/lastHourPrice)) >= .06:
server = smtplib.SMTP( "smtp.gmail.com", 587 )
server.starttls()
server.login( 'Your Email', 'Your Password' )
message = "Price of Ether = " + price[0] + "\n" + "Ether dropped " + str(round(100*(1.0 - (priceNum/lastHourPrice)), 2)) + "%"
server.sendmail( 'YOUREMAIL', 'YOURPHONENUMBER@mms.att.net', message )
#if the price of ether increases by a min of 10% in the last hour, send text
else:
if (((priceNum - lastHourPrice)/lastHourPrice)) >= .06:
server = smtplib.SMTP( "smtp.gmail.com", 587 )
server.starttls()
server.login( 'Your Email', 'Your Password' )
message = "Price of Ether = " + price[0] + "\n" + "Ether went up " + str(round(100*(((priceNum - lastHourPrice)/lastHourPrice)), 2)) + "%"
server.sendmail( 'YOUREMAIL', 'YOURPHONENUMBER@mms.att.net', message )
#hour goes by, set last hour value
lastHourPrice = priceNum;
#sleep for hour
time.sleep(3600)