Created
July 25, 2014 20:56
-
-
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
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
!/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