espn-ff
Version:
ESPN Fantasy Football Scraper
37 lines • 1.37 kB
JavaScript
;
var cheerio = require('cheerio');
var OwnersParser = (function () {
function OwnersParser() {
this.name = 'owners';
}
OwnersParser.prototype.parse = function (context) {
var _this = this;
var result = [];
var table = context.selector('table.tableBody:nth-of-type(1)');
if (table.length === 0)
return null;
var rows = table.children('.ownerRow').each(function (index, row) {
var team = _this.parseOwnerRow(row);
if (team) {
result.push(team);
}
});
return result;
};
OwnersParser.prototype.parseOwnerRow = function (element) {
var id = cheerio('td:nth-of-type(1)', element).text();
if (!id || id.length === 0 || id.trim().length === 0)
return null;
return {
id: parseInt(id),
short_name: cheerio('td:nth-of-type(2)', element).text(),
name: cheerio('td:nth-of-type(3)', element).text(),
division: cheerio('td:nth-of-type(4)', element).text(),
owner_name: cheerio('td:nth-of-type(5)', element).text()
};
};
return OwnersParser;
}());
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = OwnersParser;
//# sourceMappingURL=Owners.js.map