I'm trying to get the href attributes with trumpet and keep stalling at the Object (...href attribute...) has no method 'push'
error. Same thing happens when trying to use the createWriteStream
. The docs for this method mention a second parameter like this elem.getAttribute(name, cb)
, but I have no idea what cb
is.
var file = "...path...";
var links = [];
var trumpet = require('trumpet');
var tr = trumpet();
tr.selectAll('.list_album', function(album) {
album.getAttribute('href').push(links);
});
var fs = require('fs');
fs.createReadStream(file).pipe(tr);
console.log(links);
push
is a method on Array
and your links
object is an Array
so it seems to me what you want to do is:
tr.selectAll('.list_album', function(album) {
album.getAttribute('href', function (value) {
links.push(value);
});
});
I'm not familiar with trumpet but I'd expect this to work.