Created
April 13, 2016 17:40
-
-
Save wosc/0ea43e23d7efd4f4784540c174f0e80d to your computer and use it in GitHub Desktop.
Backup all your delicious.com bookmarks by scraping the UI-facing API
This file contains hidden or 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
import json | |
import requests | |
import sys | |
BASE_URL = 'https://avosapi.delicious.com/api/v1/posts/you/time' | |
def get_bookmarks(entry, auth): | |
if not entry: | |
r = requests.get(BASE_URL, auth=auth) | |
else: | |
r = requests.get('%s?anchorx=%s%s' % ( | |
BASE_URL, entry['time_created'], entry['md5']), auth=auth) | |
data = r.json() | |
return data['pkg'] | |
if __name__ == '__main__': | |
if len(sys.argv) < 3: | |
sys.stderr.write('Usage: %s username password\n' % sys.argv[0]) | |
sys.exit(1) | |
auth = (sys.argv[1], sys.argv[2]) | |
bookmarks = [] | |
page = get_bookmarks(None, auth) | |
while True: | |
if not page: | |
break | |
bookmarks.extend(page) | |
page = get_bookmarks(page[-1], auth) | |
json.dump(bookmarks, sys.stdout) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
FYI domain "delicious.com" is dead, now use "del.icio.us", but it seems the base API url has changed., any idea ?
thanks
P.