So do I just put it in the same directory or something?
Here's my code, btw:
Code:# Importing all the modules from pprint import pprint import requests import json # Set username and password username = 'USERNAMEHERE' password = 'PASSWORDHERE' # Create dict with username and password user_pass_dict = {'user': username, 'passwd': password, 'api_type': 'json'} # Set the header for all the following requests headers = {'user-agent': 'SuperFakeHeaders v1.0', } # Create a requests.session that will handle our cookies for us client = requests.session() client.headers=headers # Make a login request, passing in the user and password as data r = client.post(r'http://www.reddit.com/api/login', data=user_pass_dict) # Print to confirm error-free response pprint(r.content) # Turns the response's JSON to a native python dict j = json.loads(r.content) # Grabs the modhash from the response client.modhash = j['json']['data']['modhash'] # Prints the user's modhash print '{USER}\'s modhash is: {mh}'.format(USER=username, mh=client.modhash)
Results 1 to 6 of 6
Threaded View
- 08 Apr. 2013 09:04pm #3
- Join Date
- Apr. 2010
- Location
- When freedom is outlawed only outlaws will be free
- Posts
- 5,113
- Reputation
- 195
- LCash
- 5.42