-
Notifications
You must be signed in to change notification settings - Fork 0
/
httpGet.py
59 lines (47 loc) · 1.31 KB
/
httpGet.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
import requests
import json
import datetime
import smtplib
## Bitcoin
'''
r = requests.get("https://www.zebapi.com/api/v1/market/ticker/btc/inr")
data = json.loads(r.content)
print(data["buy"])
print(data["sell"])
B = int(data["buy"])
S = int(data["sell"])
if B>S:
print("Difference: " + str(B-S))
'''
## Train Details
'''
r = requests.get("https://api.railwayapi.com/v2/live/train/12010/date/14-09-2017/apikey/dx8s8oak/")
data = json.loads(r.content)
if r.status_code == 200:
print("Total number of Stations: " + str(len(data["route"])))
for x in range(len(data["route"])):
print(data["route"][x]["station"]["name"])
else:
print("Error fetching data")
'''
# Time
'''
#Time = datetime.datetime.now().time()
Time = datetime.datetime.now().time().hour
minute = datetime.datetime.now().time().minute
time = int(Time) - 12
if time < 12:
print(str(time) + ":" + str(minute) + " pm")
else:
print(str(time) + ":" + str(minute) + " am")
'''
# Email
sender = 'yashsoni2017@gmail.com'
receivers = ['yashsoni2017@gmail.com']
message = "From"
try:
smtpObj = smtplib.SMTP('localhost')
smtpObj.sendmail(sender, receivers, message)
print "Successfully sent email"
except NameError:
print "ohh.. didnt work."