Skip to content

Instantly share code, notes, and snippets.

@philgruneich
Created November 17, 2014 02:22
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philgruneich/9450299366c67b608fb8 to your computer and use it in GitHub Desktop.
Save philgruneich/9450299366c67b608fb8 to your computer and use it in GitHub Desktop.
Send entire feed to Pinboard
#coding: utf-8
import feedparser
import urllib
import bs4
import keychain
import console
import pickle
# Get your token at:
# http://pinboard.in/settings/password
token = keychain.get_password('pinboardapitoken','pinboard')
if token is not None:
token = pickle.loads(token)
else:
token = pickle.dumps(console.input_alert('Pinboard API Token'))
keychain.set_password('pinboardapitoken', 'pinboard', token)
# Add the link for the RSS you'd like to send to Pinboard
rss = console.input_alert('RSS feed URL')
print 'Loading feed...'
feed = feedparser.parse(rss)
entries = feed['entries']
#replace the ‘starred’ with other tag you want.
tags = urllib.quote('starred')
for entry in entries:
query = 'https://api.pinboard.in/v1/posts/add?auth_token=' + token + '&url=' + urllib.quote(entry['link']) + '&description=' + urllib.quote(entry['title'].encode('utf-8')) + '&tags=' + tags
pinboard = bs4.BeautifulSoup(urllib.urlopen(query))
print 'Added to Pinboard: ' + entry['title']
print 'Success! Added all available feed articles!'
console.hide_output()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment