Commit d908c1ab d908c1ab44901e7224167895b941c58cadc2b7f2 by Nicolas Perriault

added metaextract sample scripts

1 parent 930f368c
Subproject commit 50c9d3f003479ee6b62249a5ad33fa3648e9daa9
Subproject commit 2029165d028c53aa9223e75d2505dd3b8a9002a9
......
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();
});
......@@ -13,7 +13,7 @@ var casper = require('casper').create({
// Overriding Casper.open to prefix all test urls
casper.setFilter('open.location', function(location) {
if (!/^http/.test(location)) {
return 'file://' + phantom.casperPath + '/' + location;
return f('file://%s/%s', phantom.casperPath, location);
}
return location;
});
......