-
Notifications
You must be signed in to change notification settings - Fork 21
/
scraper.js
43 lines (36 loc) · 1.04 KB
/
scraper.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
40
41
42
43
const cheerio = require("cheerio");
const axios = require("axios");
const siteUrl = "https://remoteok.io/";
let siteName = "";
const categories = new Set();
const tags = new Set();
const locations = new Set();
const positions = new Set();
const fetchData = async () => {
const result = await axios.get(siteUrl);
return cheerio.load(result.data);
};
const getResults = async () => {
const $ = await fetchData();
siteName = $('.top > .action-post-job').text();
$(".tags .tag").each((index, element) => {
tags.add($(element).text());
});
$(".location").each((index, element) => {
locations.add($(element).text());
});
$("div.nav p").each((index, element) => {
categories.add($(element).text());
});
$('.company_and_position [itemprop="title"]').each((index, element) => {
positions.add($(element).text());
});
return {
positions: [...positions].sort(),
tags: [...tags].sort(),
locations: [...locations].sort(),
categories: [...categories].sort(),
siteName,
};
};
module.exports = getResults;