Skip to content

Instantly share code, notes, and snippets.

@nbardiuk
Created October 19, 2012 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbardiuk/3917941 to your computer and use it in GitHub Desktop.
Save nbardiuk/3917941 to your computer and use it in GitHub Desktop.
Download picasa album using rss file
#!/usr/bin/env python
import urllib
import re
import os
from BeautifulSoup import BeautifulSoup
def downloadImages(file):
file_handler = open(file).read()
soup = BeautifulSoup(file_handler)
directory = soup.find('title').text
print directory
if not os.path.exists(directory):
os.makedirs(directory)
for item in soup.findAll('item'):
name = item.find('title').text
enclosure = item.find('enclosure')
url = re.sub(r'(^.*/)([^/]*)$', r'\1s0/\2', enclosure['url'])
print url, name
urllib.urlretrieve(url, directory+'/'+name)
if __name__ == "__main__":
folder = 'rss/'
dirList=os.listdir(folder)
for file_name in dirList:
downloadImages(folder + file_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment