Created
February 17, 2013 01:44
-
-
Save mikedewar/4969641 to your computer and use it in GitHub Desktop.
This is an example script to get the list of articles on your instapaper account. You need to ask Instapaper for xauth access and you (or your user) need to be an instapaper subscriber ($3 a month) to be able to see the API.
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
from __future__ import unicode_literals | |
from urlparse import parse_qs | |
import requests | |
from requests_oauthlib import OAuth1 | |
key = "key" | |
secret ="secret" | |
oauth = OAuth1(key, secret) | |
instaaccount = "username" | |
instapassword = "password" | |
params = {} | |
params["x_auth_username"] = instaaccount | |
params["x_auth_password"] = instapassword | |
params["x_auth_mode"] = 'client_auth' | |
request_token_url = 'https://www.instapaper.com/api/1/oauth/access_token' | |
r = requests.post(url=request_token_url, auth=oauth, data=params) | |
credentials = parse_qs(r.content) | |
oauth_token = credentials.get('oauth_token')[0] | |
oauth_secret = credentials.get('oauth_token_secret')[0] | |
oauth = OAuth1(key, secret+"&"+oauth_secret, oauth_token) | |
list_url = 'https://www.instapaper.com/api/1/bookmarks/list' | |
params = { | |
"username": instaaccount, | |
"password": instapassword | |
} | |
r = requests.post(list_url, auth=oauth, data=params) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment