Skip to content

Instantly share code, notes, and snippets.

@c7h c7h/gist:5521563
Created May 5, 2013

What would you like to do? image download script (via firefox bookmarks)
#! /usr/bin/env python
Created on 05.05.2013
@author: christoph gerneth
ugly, short hack!
read in firefox bookmarks and
download images from
import sys
import json
import urllib2
import re
import HTMLParser
from subprocess import call
with open(sys.argv[1], "r") as f:
x =
jout = json.loads(x)
root = jout["children"][1]["children"][10]["children"]
#pattern : (?<=url\()(((f|ht){1}tp[s]?://)[-a-zA-Z0-9@:%_\+.~#?&//=;\\]+)
maxgif_pattern = r'(?<=url\()(((f|ht){1}tp[s]?://)[-a-zA-Z0-9@:%_\+.~#?&//=;\\]+)'
_htmlparser = HTMLParser.HTMLParser()
unescape = _htmlparser.unescape
img_list = []
for entry in root:
entry_uri = entry["uri"]
if "maxgif" in entry_uri:
#this is a maxif uri
sitedata = unescape(urllib2.urlopen(entry_uri, timeout=100).read())
found = re.findall(maxgif_pattern, sitedata)
print "found %s on site %s" % (found[0][0], entry_uri)
# ok - now, download everything
call("wget %s" % " ".join(img_list), shell=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.