menio
production-quality template convention to scrap web sites based on cheerio
Installation
$ npm install menio
A Menio template
moduleexports = // Selector context: selector: 'table > tr' index: 4 // Properties props: { var numeros = $scope; // return scope and next = true if this only selects for another template, only available in callback mode return $scope: numeros next: true ; } ;
Another Menio template
moduleexports = context: 'td' props: { // either return or assign to this.model return $scopetext; } { return $scopetext; } { return numero: $scopetext serie: $scopetext folio: $scopetext verificacion: $scopetext letras: $scopetext ; } { return numero: $scopetext ; } { return numero: $scopetext ; } { return 'es-pa'; } { return this + this; } ;
Menio Docs
new Menio(templateDirectory)
menio.parse(htmlOrDOM, templateName, callback)
menio.render(options { template, data }, callback)
Callback(err, scope, model)
Menio Template Docs
Property(scope, cheerio, underscore)
Property(scope, cheerio, underscore)
Response(either value or options)
Response Options($scope, next), only available in callback mode
Example
// add template directory var menio = __dirname + '/templates'; // async callback // 1st argument - either a $ element or HTML // 2nd argument - name of the template // 3rd and optional - callback menio; });
Changelog
- 0.2.0: Better API with $scope.$find, context selector index and added render (same as parse) which accepts an options argument
License
Copyright 2015 Rogelio Morrell C. MIT License