#!/usr/bin/env python #blogger-back.py #Copyright 2007 John C. Vernaleo #john@netpurgatory.com #v0.5 04/30/2007 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # #This is an extremely simple way to back up a blog on Google's #blogger beta (the one using your google account) and its comments. #You must set site feed to full from dashboard. #This is only capable of saving the 1000 most recent comments and posts #due to the way the search works on blogger. #It saves xml files for easy import into other things, but no #style info. #Also, pictures posted are not saved. To do a decent job of saving pictures, #one would probably need to log onto picasa. #Ideally, a better solution to all this is to use the blogger and picasa #APIs that Google provides. But for the moment, this will have to do. import urllib import datetime import sys # def get_blog(name): stamp=str(datetime.date.today()) savepost=name+"-posts-"+stamp+".xml" savecomment=name+"-comments-"+stamp+".xml" postxmlurl="http://"+name+".blogspot.com/feeds/posts/default?max-results=1000" commentxmlurl="http://"+name+".blogspot.com/feeds/comments/default?max-results=1000" urllib.urlretrieve(postxmlurl,savepost) urllib.urlcleanup() urllib.urlretrieve(commentxmlurl,savecomment) urllib.urlcleanup() print "Retrieved "+postxmlurl+" and "+commentxmlurl+" on "+stamp if __name__ == "__main__": if(len(sys.argv)<=1): print "Error, must give blog name on command line!" sys.exit() name=sys.argv[1] get_blog(name)