Skip to content

Instantly share code, notes, and snippets.

@jaimemrjm
Forked from chrisgeo/delicious.py
Last active November 3, 2015 22:50
Show Gist options
  • Save jaimemrjm/cd880e6f204d660d0028 to your computer and use it in GitHub Desktop.
Save jaimemrjm/cd880e6f204d660d0028 to your computer and use it in GitHub Desktop.
Delicious CSV Import Script (for Diigo CSV file)
#!/usr/bin/env python
import csv
import httplib2
import time
try:
from urllib import urlencode
except ImportError:
from urllib.parse import urlencode
# EDIT HERE YOUR CONFIG #
username = "replaceme"
password = "replaceme"
ifile = '/tmp/import.csv'
add_url = 'https://api.del.icio.us/v1/posts/add?%s'
ifile = ''
headers = {'User-Agent': 'Delicious CSV Import'}
bookmarks = csv.DictReader(open(ifile, 'r'))
for row in bookmarks:
post_dict = {}
post_dict['url'] = row['url']
post_dict['description'] = row['title']
post_dict['tags'] = row['tags']
post_dict['replace'] = 'no'
print(post_dict)
h = httplib2.Http()
h.add_credentials(username, password)
params = urlencode(post_dict)
resp, content = h.request(add_url % params, "GET", headers=headers)
print(resp)
print(content)
#they ask us to pause for at least a second, give them 2 to be kosher.
time.sleep(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment