Created
September 7, 2011 17:37
-
-
Save alxhill/1201212 to your computer and use it in GitHub Desktop.
Statify - turn a dynamic page static
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/python | |
import sys | |
import urllib | |
import os | |
def statify(baseurl, pages, folder, home=True): | |
os.mkdir(folder) | |
baseurl = baseurl if baseurl[-1] is "/" else baseurl + "/" | |
full_pages = [ baseurl + page for page in pages ] | |
for i, page in enumerate(full_pages): | |
urllib.urlretrieve(page, folder + "/" + pages[i]) | |
if home: | |
urllib.urlretrieve(baseurl, folder + "/index.html") | |
### - Example Use - ### | |
def main(): | |
pages = ["about.html", "contact.html", "portfolio.html", "online.html", "clients.html"] | |
base = "http://example.com/" | |
folder = sys.argv[1] if sys.argv[1] else "statified" | |
statify(base, pages, folder) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment