Created
August 19, 2011 09:27
-
-
Save mgax/1156437 to your computer and use it in GitHub Desktop.
Download piratepad documents as html files to a git repository
This file contains hidden or 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 urllib2 | |
import re | |
import subprocess | |
from time import strftime | |
url_list = [ | |
] | |
def main(): | |
for url in url_list: | |
doc = re.search('/\w*$',url).group()[1:] | |
url = 'http://piratepad.net/ep/pad/export/'+doc+'/latest?format=html' | |
http = urllib2.urlopen(url) | |
with open(doc + '.html', 'w') as f: | |
f.write(http.read()) | |
http.close() | |
print 'Downloaded ' + url | |
subprocess.check_call(['git', 'add', '.']) | |
subprocess.check_call(['git', 'commit', '-a', | |
'-m Automated backup %s'%( | |
strftime("%Y-%m-%d %H:%M:%S"))]) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment