Created
October 19, 2012 12:13
-
-
Save nbardiuk/3917941 to your computer and use it in GitHub Desktop.
Download picasa album using rss 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 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