-
-
Save jaimemrjm/cd880e6f204d660d0028 to your computer and use it in GitHub Desktop.
Delicious CSV Import Script (for Diigo CSV file)
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/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