-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcity_finder.py
52 lines (37 loc) · 1.09 KB
/
city_finder.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
from __future__ import unicode_literals
from meetup_api import group_finder
import requests
import json
import time
import codecs
import sys
UTF8Writer = codecs.getwriter('utf8')
sys.stdout = UTF8Writer(sys.stdout)
cities = list()
params = dict()
def main():
#cities =[("Bridgeport","CT"),("New Haven","CT"),("Hartford","CT"),("Stamford","CT"),("Waterbury","CT")]
api_key= ""
per_page = 4
res = per_page
offset = 0
params = {"sign":"true","country":"US", "key":api_key, "page":per_page }
response=getResponse(**params)
time.sleep(1)
offset += 1
res = response['meta']['count']
for x in range(len(response["results"])):
city = response["results"][x]["city"]
state = response["results"][x]["state"]
#print city, state
tup = (city, state)
cities.append(tup)
print cities
group_finder(cities)
#time.sleep(1)
def getResponse(**params):
request = requests.get("http://api.meetup.com/2/cities",params=params)
data = request.json()
return data
if __name__=="__main__":
main()