Hey guys and ladies first of all this is my first question here in stackoverflow so don't be so hard on me.. but w/e :P.
I have a problem..
i'm totally new to web scraping and at the moment i have the problem that i can't select the right elements. My code looks like this:
var express = require('express');
var path = require('path');
var request = require('request');
var cheerio = require('cheerio');
var fs = require('fs');
var app = express();
var port = 8000;
var url = http://www.finanzparasiten.de/html/links/awd.html;
request(url, function (err, resp, body) {
if(!err) {
var $ = cheerio.load(body)
var test = $('body table table table > tbody > tr > td > p');
console.log(test.html())
test.each(function (ii, asdf) {
var rr = $(asdf).find(table).find(tr).first().find('td:nth-child(2)').text();
console.log(asdf);
})
} else {
console.log(we encountered an error: + err);
}
});
app.listen(port);
console.log('server is listening on ' + port);
It keeps logging NULL for the variable test.
It seems like cheerio has problems with the > selector. With jQuery this selection would work as expected.
Thanks to @logol's anwser i could solve the first problem but now i facing the problem that i have to select direct childs after body and it seems to bug as the tbody.. any1 got a workaround?