Skip to content

Instantly share code, notes, and snippets.

@mgax
Created August 19, 2011 09:27
Show Gist options
  • Save mgax/1156437 to your computer and use it in GitHub Desktop.
Save mgax/1156437 to your computer and use it in GitHub Desktop.
Download piratepad documents as html files to a git repository
#!/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