diff --git a/.gitignore b/.gitignore index 0b947d3..74a3816 100644 --- a/.gitignore +++ b/.gitignore @@ -104,4 +104,6 @@ dist .tern-port test.js -exclude/ \ No newline at end of file +exclude/ + +node_modules \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e378357..4f07a78 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "axios": "^1.4.0", "jssoup": "^0.0.15", - "peviitor_jsscraper": "^0.1.3", + "peviitor_jsscraper": "^0.1.4", "querystring": "^0.2.1", "uuid": "^9.0.0" } @@ -118,9 +118,9 @@ } }, "node_modules/peviitor_jsscraper": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/peviitor_jsscraper/-/peviitor_jsscraper-0.1.3.tgz", - "integrity": "sha512-UjiQzKsVqTaWZ3MochmE4wYuyT6RfYDz3rjJs8aKeHHBJjv+8rqfuDjlCPoRHT4lxktrtCbl7DKalz+0Y3waGQ==", + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/peviitor_jsscraper/-/peviitor_jsscraper-0.1.4.tgz", + "integrity": "sha512-b/F3VJblyri2B91WS3jv9yHJvg8dx8u2//tDJM8cctr7q/gcJ3wuWt9YPxGr5kEnTXNghqr8C2MCvxCvhFRzhA==", "dependencies": { "axios": "^1.4.0", "jssoup": "^0.0.15", @@ -221,9 +221,9 @@ } }, "peviitor_jsscraper": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/peviitor_jsscraper/-/peviitor_jsscraper-0.1.3.tgz", - "integrity": "sha512-UjiQzKsVqTaWZ3MochmE4wYuyT6RfYDz3rjJs8aKeHHBJjv+8rqfuDjlCPoRHT4lxktrtCbl7DKalz+0Y3waGQ==", + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/peviitor_jsscraper/-/peviitor_jsscraper-0.1.4.tgz", + "integrity": "sha512-b/F3VJblyri2B91WS3jv9yHJvg8dx8u2//tDJM8cctr7q/gcJ3wuWt9YPxGr5kEnTXNghqr8C2MCvxCvhFRzhA==", "requires": { "axios": "^1.4.0", "jssoup": "^0.0.15", diff --git a/package.json b/package.json index 649fbe4..f6f3416 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "dependencies": { "axios": "^1.4.0", "jssoup": "^0.0.15", - "peviitor_jsscraper": "^0.1.3", + "peviitor_jsscraper": "^0.1.4", "querystring": "^0.2.1", "uuid": "^9.0.0" } diff --git a/sites/pirelli.js b/sites/pirelli.js new file mode 100644 index 0000000..e532a65 --- /dev/null +++ b/sites/pirelli.js @@ -0,0 +1,49 @@ +const { Scraper, postApiPeViitor } = require("peviitor_jsscraper"); + +const generateJob = (job_title, job_link, city) => ({ + job_title, + job_link, + country: "Romania", + city, +}); + +const getJobs = async () => { + const url = "https://corporate.pirelli.com/corporate/en-ww/careers/work-with-us?region=europe&country=romania&function=all"; + const scraper = new Scraper(url); + const type = "HTML"; + const soup = await scraper.get_soup(type); + const jobElements = soup.findAll('div', { 'data-country': "0c7d5ae44b2a0be9ebd7d6b9f7d60f20" }); + const jobs = []; + jobElements.forEach((el) => { + const job_title = el.find('span').text.trim(); + const city = el.find('span', { 'class': "loc" }).text.trim(); + const jumpTo = "#:~:text="; + const job_link = url + jumpTo + job_title; + const job = generateJob(job_title, job_link, city); + jobs.push(job); + }); + return jobs; +}; + +const getParams = () => { + const company = "Pirelli"; + const logo = + "https://d2snyq93qb0udd.cloudfront.net/corporate/logo-pirelli2x.jpg"; + const apikey = process.env.KNOX; + const params = { + company, + logo, + apikey, + }; + return params +}; + +const run = async () => { + const jobs = await getJobs(); + const params = getParams(); + await postApiPeViitor(jobs, params); +}; + +run(); // this will be called by our main.js job + +module.exports = { getJobs, getParams }; // this is needed for our unit test job \ No newline at end of file