Last active
July 21, 2017 15:43
-
-
Save harrietty/c4fa2ac0acf498d154e40c3ad5de34cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cheerio = require('cheerio'); | |
const moment = require('moment'); | |
function extractListingsFromHTML (html) { | |
const $ = cheerio.load(html); | |
const vacancyRows = $('.view-Vacancies tbody tr'); | |
const vacancies = []; | |
vacancyRows.each((i, el) => { | |
// Extract information from each row of the jobs table | |
let closing = $(el).children('.views-field-field-vacancy-deadline').first().text().trim(); | |
let job = $(el).children('.views-field-title').first().text().trim(); | |
let location = $(el).children('.views-field-name').text().trim(); | |
closing = moment(closing.slice(0, closing.indexOf('-') - 1), 'DD/MM/YYYY').toISOString(); | |
vacancies.push({closing, job, location}); | |
}); | |
return vacancies; | |
} | |
module.exports = { | |
extractListingsFromHTML | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment