Skip to content

Commit

Permalink
Fixed Regnology scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalaurentiu committed Oct 12, 2023
1 parent d0f79b9 commit c8c83f3
Showing 1 changed file with 52 additions and 42 deletions.
94 changes: 52 additions & 42 deletions sites/regnology.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,53 @@
"use strict";
const scraper = require("../peviitor_scraper.js");
const uuid = require("uuid");

const url = "https://www.regnology.net/en/careers/?city=Romania#jobs";

const company = { company: "Regnology" };
let finalJobs = [];

const s = new scraper.Scraper(url);

s.soup
.then((soup) => {
const jobs = soup.find("ul", { class: "link-list" }).findAll("li");

jobs.forEach((job) => {
const id = uuid.v4();
const job_title = job.find("a").text.trim();
const job_link = "https://www.regnology.net" + job.find("a").attrs.href;

finalJobs.push({
id: id,
job_title: job_title,
job_link: job_link,
city: "Romania",
country: "Romania",
company: company.company,
});
});
})
.then(() => {
console.log(JSON.stringify(finalJobs, null, 2));

scraper.postApiPeViitor(finalJobs, company);

let logo = "https://www.regnology.net/project/frontend/build/logo-regnology.7537d456.svg";

let postLogo = new scraper.ApiScraper(
"https://api.peviitor.ro/v1/logo/add/"
);
postLogo.headers.headers["Content-Type"] = "application/json";
postLogo.post(JSON.stringify([{ id: company.company, logo: logo }]));
const { Scraper, postApiPeViitor } = require("peviitor_jsscraper");

const generateJob = (job_title, job_link) => ({
job_title,
job_link,
country: "Romania",
city: "Sibiu",
county: "Sibiu",
remote: [],
});

const getJobs = async () => {
let url =
"https://www.regnology.net/en/careers/?city=Romania#jobs";
const jobs = [];
const scraper = new Scraper(url);

let res = await scraper.get_soup("HTML");
let items = res.find("ul", { class: "link-list" }).findAll("li");

items.forEach((item) => {
const job_title = item.find("h3").text.trim();
const job_link = "https://www.regnology.net" + item.find("a").attrs.href;

jobs.push(generateJob(job_title, job_link));
});
return jobs;
};

const getParams = () => {
const company = "Regnology";
const logo =
"https://www.regnology.net/project/frontend/build/logo-regnology.7537d456.svg";
const apikey = process.env.APIKEY;
const params = {
company,
logo,
apikey,
};
return params;
};

const run = async () => {
const jobs = await getJobs();
const params = getParams();
postApiPeViitor(jobs, params);
};

if (require.main === module) {
run();
}

module.exports = { run, getJobs, getParams }; // this is needed for our unit test job

0 comments on commit c8c83f3

Please sign in to comment.