Created
June 28, 2012 03:03
-
-
Save chrisgeo/3008600 to your computer and use it in GitHub Desktop.
Delicious CSV Import Script
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
#!/usr/bin/env python | |
import csv | |
import httplib2 | |
import time | |
from urllib import urlencode | |
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['Folder'] | |
post_dict['replace'] = 'no' | |
print post_dict | |
h = httplib2.Http() | |
h.add_credentials(username, pass) | |
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
How to use it, can you specify an example of command line ?
Thanks!
EDIT : I found. Import succeed.