Commit d7458b17 d7458b17b646842ea40f5412a039019d20cbd8df by Nicolas Perriault

added metaextract sample scripts

1 parent 930f368c
casper = require("casper").create()
url = casper.cli.get 0
metas = []
if not url
casper.echo "Usage: casperjs [url]"
casper.exit()
casper.start url, ->
metas = @evaluate ->
metas = []
castarray = (arr) -> [].slice.call(arr)
for elem in castarray document.querySelectorAll "meta"
meta = {}
for attr in castarray elem.attributes
meta[attr.name] = attr.value
metas.push meta
metas
casper.run ->
require("utils").dump metas
this.exit()
var casper = require("casper").create()
, url = casper.cli.get(0)
, metas = [];
if (!url) {
casper.echo('Usage: casperjs [url]').exit();
}
casper.start(url, function() {
metas = this.evaluate(function() {
var metas = [];
[].forEach.call(document.querySelectorAll('meta'), function(elem) {
var meta = {};
[].slice.call(elem.attributes).forEach(function(attr) {
meta[attr.name] = attr.value;
});
metas.push(meta);
});
return metas;
});
});
casper.run(function() {
require("utils").dump(metas);
this.exit();
});