Last active
July 13, 2016 22:50
-
-
Save VMuliadi/34fcaacbc40cf0df0359bb67d6dc25b2 to your computer and use it in GitHub Desktop.
A simple application that can automatically generate Bootstrap CSS, Bootstrap JS, and jQuery on a single HTML file. Launch this application and ready to go
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
import sys | |
import urllib2 | |
from bs4 import BeautifulSoup | |
# CSS and JS for Bootstrap | |
url = "https://www.bootstrapcdn.com/" | |
page = urllib2.urlopen(url) | |
bsoup = BeautifulSoup(page, 'lxml') | |
js_link = bsoup.find('input', {'id': 'quickstartjs_form'}).get('value') | |
css_link = bsoup.find('input', {'id': 'quickstartcss_form'}).get('value') | |
# jQuery link | |
jquery2_link = '' | |
url = "https://code.jquery.com/" | |
page = urllib2.urlopen(url) | |
bsoup = BeautifulSoup(page, 'lxml') | |
jquery2_wrapper = bsoup.find_all('a', {'class': 'open-sri-modal'}) | |
for jquery2_src in jquery2_wrapper: | |
link_part = jquery2_src.get('href') | |
if link_part.find('jquery-2.') != -1 and link_part.find('min.js') != -1: | |
jquery2_link = url + link_part | |
# export to file | |
output = open("index.html", "w") | |
output.write("<!DOCTYPE HTML>\n") | |
output.write("<html>\n") | |
output.write("\t<head>\n") | |
output.write("\t<script type='text/javascript' src='%s'></script>\n" % jquery2_link) | |
output.write("\t\t<link rel='stylesheet' href='%s' />\n" % css_link) | |
output.write("\t</head>\n") | |
output.write("\t<body>\n") | |
output.write("\t\t\n") | |
output.write("\t</body>\n") | |
output.write("\t<script type='text/javascript' src='%s'></script>\n" % js_link) | |
output.write("</html>") | |
output.close() | |
sys.exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment