Created
July 27, 2012 22:34
-
-
Save dtgay/3190781 to your computer and use it in GitHub Desktop.
Problem with Stack Exchange API JSON data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stack_exchange_api = 'https://api.stackexchange.com/2.1' | |
request_url = "{0}/users/{1}/associated".format( | |
stack_exchange_api, usernames['stack_exchange']) | |
api_request = urllib2.Request( | |
request_url, | |
headers={"Accept": "application/json"}) | |
api_response = urllib2.urlopen(api_request) | |
se_accounts_json = json.load(api_response) | |
se_answers = 0 # Number of answers given on SE sites | |
pprint.pprint(se_accounts_json) | |
for site in se_accounts_json['items']: | |
se_answers += site['answer_count'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment