Skip to content

Instantly share code, notes, and snippets.

@Paanini
Created July 25, 2014 20:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Paanini/0bb781f98a59d863b434 to your computer and use it in GitHub Desktop.
Save Paanini/0bb781f98a59d863b434 to your computer and use it in GitHub Desktop.
Python script to fetch URLs of all articles from Pocket (http://getpocket.com) that have been favourited in the last 24 hours
!/usr/bin/python
import requests, json, datetime
access_token = "ENTER_YOUR_ACCESS_TOKEN"
consumer_key = "ENTER_YOUR_CONSUMER_KEY"
get_url = 'https://getpocket.com/v3/get'
#Find the Unix Epoch timestamp exactly 24 hours before now
since = int(datetime.datetime.now().strftime("%s")) - 86400
#This HTTP POST request will return details of all Pocket articles favourited in the last 24 hours
params = {'consumer_key' : consumer_key , 'access_token' : access_token , 'favorite' : 1 , 'since' : str(since)}
a = requests.post(get_url, params=params)
response = json.loads(a.text)['list']
with open("favourited_urls","a") as file:
for item in response:
url = response.get(item).get('resolved_url')
file.write(url+"\n")
print url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment