-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeetup_rsvps.py
More file actions
32 lines (25 loc) · 827 Bytes
/
Copy pathmeetup_rsvps.py
File metadata and controls
32 lines (25 loc) · 827 Bytes
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
#!/usr/bin/python
import json
import requests
import random
def PickAWinner():
url = 'https://api.meetup.com/2/rsvps'
params = dict(
key='XXXXXXXXXXXXXXXXXXXX', # Replace with your Meetup.com API key
event_id='YYYYYYYYY', # Replace with your Meetup.com event ID
order='name'
)
resp = requests.get(url=url, params=params)
data = json.loads(resp.text)
response = resp.text
# with open('response.json', 'w') as outfile:
# json.dump(data, outfile)
j = json.loads(response.encode('ascii', 'ignore').decode()) # This is a Python Dict (JSON array)
i = 0
results = j['results']
members = dict()
while i < len(results):
rsvp = results[i]
members[i] = str(rsvp['member']['name'])
i += 1
return str(random.choice(members))