Crawl rendered JavaScript templates from a local server.
Project description
Command line tool that crawls a local webserver with a headless browser and outputs static html files. Works well with html5validator to validate HTML5 from dynamic content with Javascript.
Run localcrawl --help:
PhantomJS is required. It is pre-installed on TravisCI. On a Mac run brew install PhantomJS.
Example Command
localcrawl --start _build/html/index.html --out _crawled/ --depth 3
Mustache Example
This can be used to convert templated files to HTML files (e.g. for validation with html5validator).
Input:
<html>
<head>
<title>Mustache Test</title>
</head>
<body>
<div id="output"></div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.2.1/mustache.min.js"></script>
<script>
var data = {
item: 'Fork',
price: function() { return (1.10 * 1.08).toFixed(2); },
};
var html = Mustache.render('{{item}}: <b>${{price}}</b>', data);
document.getElementById('output').innerHTML = html;
</script>
</body>
</html>
The crawled output includes the output from processing the template (Fork: <b>$1.19</b>):
<html><head>
<title>Mustache Test</title>
</head>
<body>
<div id="output">Fork: <b>$1.19</b></div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.2.1/mustache.min.js"></script>
<script>
var data = {
item: 'Fork',
price: function() { return (1.10 * 1.08).toFixed(2); },
};
var html = Mustache.render('{{item}}: <b>${{price}}</b>', data);
document.getElementById('output').innerHTML = html;
</script>
</body></html>
Should play nice with:
JavaScript template engines / JS frameworks:
Static site generators:
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
localcrawl-0.2.2.tar.gz
(5.2 kB
view hashes)
Built Distribution
Close
Hashes for localcrawl-0.2.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a136d57d1611e3b6453d2518881490193af67472e0164d6f6c76c1979c99a057 |
|
MD5 | e6cea8261e0951aba9281a15d566cdb7 |
|
BLAKE2b-256 | ce0e2e5b0d5f3b91fcf593d9435a9b981a60db8745f936def5252b931283b264 |