<filename>src/get_user_data/reddit.py<gh_stars>0
import requests
import time

APP_CLIENT = ''
APP_SECRET = ''

# TODO build in request queueing so we don't bust through rate limiting
# (aka we try to be nice people)
#
# 30 requests/minute if NO AUTH
# 60 requests/minute if AUTHED
def api_get(endpoint, params):
    headers = {
        'user-agent': 'Python:edu.illinois.cs.redditReliability:v1.0 (by /u/goodusername)'
    }

    r = None
    try:
        r = requests.get('https://api.reddit.com/' + endpoint, headers=headers)

        if (r.status_code == requests.codes.ok) :
            time.sleep(2.25)
            return r.json()
        else:
            print r.reason
            r.raise_for_status()
    except:
        return None


def oauth_dance():
    postdata = {
        'grant_type': 'client_credentials'

    }

    r = requests.post('https://www.reddit.com/api/v1/access_token')


def get_usernames():
    return get_file_contents('../config/usernames.txt')

def get_reddit_user_bios(user):

    r = api_get('user/' + user + '/about', {})

<filename>src/get_user_data/reddit.py<gh_stars>0
import requests
import time

APP_CLIENT = ''
APP_SECRET = ''

# TODO build in request queueing so we don't bust through rate limiting
# (aka we try to be nice people)
#
# 30 requests/minute if NO AUTH
# 60 requests/minute if AUTHED
def api_get(endpoint, params):
    headers = {
        'user-agent': 'Python:edu.illinois.cs.redditReliability:v1.0 (by /u/goodusername)'
    }

    r = None
    try:
        r = requests.get('https://api.reddit.com/' + endpoint, headers=headers)

        if (r.status_code == requests.codes.ok) :
            time.sleep(2.25)
            return r.json()
        else:
            print r.reason
            r.raise_for_status()
    except:
        return None


def oauth_dance():
    postdata = {
        'grant_type': 'client_credentials'

    }

    r = requests.post('https://www.reddit.com/api/v1/access_token')


def get_usernames():
    return get_file_contents('../config/usernames.txt')

def get_reddit_user_bios(user):

    r = api_get('user/' + user + '/about', {})

# TODO build in request queueing so we don't bust through rate limiting # (aka we try to be nice people) # # 30 requests/minute if NO AUTH # 60 requests/minute if AUTHED