Get Facebook albums with python

Since I haven’t see much script like this around the web here is a quick script to suck bunch of albums from facebooks (your own) nothing fancy just something to get you started with pyfacebook.

import os
import urllib
from facebook import Facebook

# see
# Your API key
# Application secret key

cnx = Facebook(API_KEY, SECRET_KEY)

def choose_albums(cnx):
    cnt = 1
    for row in bigthing:
        ret[cnt] = row['name'], row['aid'], row['link']
        print "%d) %s - %s" % (cnt, row['name'], row['link'])
        cnt += 1
    ans = raw_input("Choose albums (separated by ,): ")
    return [ret[int(row)] for row in ans.split(', ') ]

chosen_albums = choose_albums(cnx)
for album in chosen_albums:
    name, aid, _ =  album
    print "Album: ", (name)
    ddir = "fbgallery/%s" % name
    if not os.path.exists(ddir):
    for photo in
        url = photo['src_big']
        dest="%s/%s.jpg" % (ddir, photo['pid'])
        if not os.path.exists(dest):
            print "Getting: ", url
            urllib.urlretrieve(url, dest)

4 thoughts on “Get Facebook albums with python”

  1. Its really nice …..
    i have a question how to count likes in facebook by using python

  2. Unfortunately this is not something I have looked at you probably want to have a look on dedicated support forum like

Comments are closed.