Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Regnology scraper #88

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading