3
3
import googlemaps
4
4
import sunlight
5
5
6
+ # imports for Weather API
7
+ import urllib2
8
+ import json
9
+
6
10
from datetime import datetime
7
11
8
12
lob .api_key = "test_32f9cf853c605d272e35567fadb984b4318"
12
16
auth = tweepy .OAuthHandler ('09mB3DUJsg9agik4sGw4DJ0jA' , 'wM4focfIFuE8Gz3f2EX3dM3EHox4BVRNbedjNdchM24vRlRObL' )
13
17
auth .set_access_token ('1559211414-3ApuTjxIy7Ivr25Vn6GXHUNSEjYa8SE9H6yCbLR' , 'FosDpZ9S0pSU0omTfnbpCG8rF14S85VRVJ1wb2ngdNhgc' )
14
18
api = tweepy .API (auth )
19
+ # Weather API setup
15
20
16
21
17
22
def getAddressWithZip ():
@@ -108,6 +113,9 @@ def getAddressNoZip():
108
113
)
109
114
110
115
address = verifiedAddress ["address" ]["address_line1" ] + ", " + verifiedAddress ["address" ]["address_city" ] + ", " + verifiedAddress ["address" ]["address_state" ]
116
+ city = verifiedAddress ["address" ]["address_city" ]
117
+ state = verifiedAddress ["address" ]["address_state" ]
118
+
111
119
112
120
geocode_result = gmaps .geocode (address )
113
121
@@ -116,7 +124,19 @@ def getAddressNoZip():
116
124
117
125
congressList = sunlight .congress .locate_legislators_by_lat_lon (latitude , longitude )
118
126
119
- print "List of Representatives: "
127
+ print "\n \n Thanks for sharing your information! \n Here's some info about the current environment near " + address + ".\n "
128
+
129
+
130
+ f = urllib2 .urlopen ('http://api.wunderground.com/api/d13977cb92663c84/geolookup/conditions/q/' + state + "/" + city .replace (" " , "_" ) + '.json' )
131
+ json_string = f .read ()
132
+ parsed_json = json .loads (json_string )
133
+ location = parsed_json ['location' ]['city' ]
134
+ temp_f = parsed_json ['current_observation' ]['temp_f' ]
135
+ print "It's currently %s degrees in %s." % (temp_f , location )
136
+ f .close ()
137
+
138
+ print "\n "
139
+ print "Here's a list of Congress members who represent your area: \n "
120
140
121
141
for rep in congressList :
122
142
print rep ["title" ] + ". " + rep ["first_name" ] + " " + rep ["last_name" ]
0 commit comments