-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.js
39 lines (30 loc) · 1.28 KB
/
helpers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const cheerio = require('cheerio');
const moment = require('moment');
function extractListingsFromHTML_1 (html) {
const $ = cheerio.load(html);
// const vacancyRows = $('.view-Vacancies tbody tr');
const vacancyRows = $('.tile');
const apts = [];
/* const head = $('.size').text(); //teste ob es überhaupt geht
console.log("the head: ", head); */
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 = $(el).children('.views-field-field-vacancy-deadline').first().text().trim();
let size = $(el).find('.size').children().last().text().trim();
let rooms = $(el).find('.rooms').children().last().text().trim();
let price = $(el).find('.price').children().last().text().trim();
let district = "";
let address = "";
let balcony;
//let location = $(el).children('.views-field-name').text().trim();
//closing = moment(closing.slice(0, closing.indexOf('-') - 1), 'DD/MM/YYYY').toISOString();
// apts.push({closing, job, location});
apts.push({size, rooms, price, district, address});
});
console.log("HALLO BIN AUCH DA");
return apts;
}
module.exports = {
extractListingsFromHTML_1
};