-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
41 lines (30 loc) · 828 Bytes
/
test.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
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 2 17:16:19 2015
@author: Eric
For now, primarily tests out the DonorsChoose.org API
Suffixes at the end of variable names:
a: numpy array
b: boolean
d: dictionary
df: pandas DataFrame
l: list
s: string
t: tuple
Underscores indicate chaining: for instance, "foo_t_t" is a tuple of tuples
"""
import json
import requests
def main():
""" Run test script. """
# Create URL string
query_d = {'APIKey': 'DONORSCHOOSE',
'subject1': '-1'}
url = 'http://api.donorschoose.org/common/json_feed.html?'
for key, val in query_d.iteritems():
url += key + '=' + val + '&'
url = url[:-1]
# Get query results
resp = requests.get(url=url, params={})
data = json.loads(resp.text)
print(len(data[u'proposals']))