From 5cdb45a0582960a2119783713da58fea30e1a660 Mon Sep 17 00:00:00 2001 From: Renato Alencar Date: Wed, 3 Nov 2021 08:27:41 -0300 Subject: [PATCH] Translate Breezy location keys for Pipo Saude --- README.md | 34 ++++----- deps.edn | 4 +- scraped-jobs.edn | 2 +- src/clojure_empregos_brasil/boards.clj | 15 +++- src/clojure_empregos_brasil/breezy.clj | 89 +++++++++++++++++++++++ src/clojure_empregos_brasil/companies.clj | 9 ++- src/clojure_empregos_brasil/scrap.clj | 4 +- 7 files changed, 129 insertions(+), 28 deletions(-) create mode 100644 src/clojure_empregos_brasil/breezy.clj diff --git a/README.md b/README.md index aa0bbc4..bfcb72d 100644 --- a/README.md +++ b/README.md @@ -7,23 +7,23 @@ Vagas de empresas que ativamente contratam pessoas desenvolvedoras Clojure no Br ## Vagas -| Vaga | Empresa | Local | Remoto? | Onde aplicar | -|-------------------------------------------------------------------------------------|--------------|---------------------------------|---------|------------------------------------------------------------------------------------------------------------------------| -| Pessoa Desenvolvedora de Software Backend Sênior (Clojure) | Embraer | São José dos Campos | Sim | https://embraer.gupy.io/jobs/1108893?jobBoardSource=gupy_public_page | -| Full Stack Developer | Flow Finance | | Sim | https://airtable.com/embed/shrG8DnjAdAOAZm9h/tble1ghQMefhblMVK/viwOzu3raZSmdxK7Z/recGtRyuHlvFhUV0v | -| Business Security Manager | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/3400816 | -| Cloud Security Engineer Specialist | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/3339732 | -| Data Engineer | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/3264442 | -| Mobile Software Engineer | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/1776035 | -| Offensive Security Engineer Specialist | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/3410377 | -| Security Incident Responder SecOps | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/3382061 | -| Software Engineer | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/2569175 | -| Systems Engineer (SRE/DevOps) | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/3372800 | -| Tech Manager | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/2989044 | -| Engenheira de Software (vaga focada em mulheres) | Trabalho Remoto | Pipo Saúde | %LABEL_POSITION_TYPE_WORLDWIDE% | | https://pipo-saude.breezy.hr/p/2508984cb6c6-engenheira-de-software-vaga-focada-em-mulheres-trabalho-remoto | -| Pessoa Engenheira de Software (vaga focada em pessoas negras) | Pipo Saúde | %LABEL_POSITION_TYPE_WORLDWIDE% | | https://pipo-saude.breezy.hr/p/1a9152c5e824-pessoa-engenheira-de-software-vaga-focada-em-pessoas-negras | -| Pessoa Engenheira de Software (vaga focada em pessoas trans) | Trabalho Remoto | Pipo Saúde | %LABEL_POSITION_TYPE_WORLDWIDE% | | https://pipo-saude.breezy.hr/p/647061946892-pessoa-engenheira-de-software-vaga-focada-em-pessoas-trans-trabalho-remoto | -| Pessoa Engenheira de Software Sênior | Pipo Saúde | %LABEL_POSITION_TYPE_WORLDWIDE% | | https://pipo-saude.breezy.hr/p/323a55e4c15f-pessoa-engenheira-de-software-senior | +| Vaga | Empresa | Local | Remoto? | Onde aplicar | +|-------------------------------------------------------------------------------------|--------------|--------------------------|---------|------------------------------------------------------------------------------------------------------------------------| +| Pessoa Desenvolvedora de Software Backend Sênior (Clojure) | Embraer | São José dos Campos | Sim | https://embraer.gupy.io/jobs/1108893?jobBoardSource=gupy_public_page | +| Full Stack Developer | Flow Finance | | Sim | https://airtable.com/embed/shrG8DnjAdAOAZm9h/tble1ghQMefhblMVK/viwOzu3raZSmdxK7Z/recGtRyuHlvFhUV0v | +| Business Security Manager | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/3400816 | +| Cloud Security Engineer Specialist | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/3339732 | +| Data Engineer | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/3264442 | +| Mobile Software Engineer | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/1776035 | +| Offensive Security Engineer Specialist | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/3410377 | +| Security Incident Responder SecOps | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/3382061 | +| Software Engineer | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/2569175 | +| Systems Engineer (SRE/DevOps) | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/3372800 | +| Tech Manager | Nubank | São Paulo | Não | https://boards.greenhouse.io/nubank/jobs/2989044 | +| Engenheira de Software (vaga focada em mulheres) | Trabalho Remoto | Pipo Saúde | Remoto ao redor do mundo | Sim | https://pipo-saude.breezy.hr/p/2508984cb6c6-engenheira-de-software-vaga-focada-em-mulheres-trabalho-remoto | +| Pessoa Engenheira de Software (vaga focada em pessoas negras) | Pipo Saúde | Remoto ao redor do mundo | Sim | https://pipo-saude.breezy.hr/p/1a9152c5e824-pessoa-engenheira-de-software-vaga-focada-em-pessoas-negras | +| Pessoa Engenheira de Software (vaga focada em pessoas trans) | Trabalho Remoto | Pipo Saúde | Remoto ao redor do mundo | Sim | https://pipo-saude.breezy.hr/p/647061946892-pessoa-engenheira-de-software-vaga-focada-em-pessoas-trans-trabalho-remoto | +| Pessoa Engenheira de Software Sênior | Pipo Saúde | Remoto ao redor do mundo | Sim | https://pipo-saude.breezy.hr/p/323a55e4c15f-pessoa-engenheira-de-software-senior | ## Empresas que usam Clojure sem vagas no momento ou sem listagem pública diff --git a/deps.edn b/deps.edn index 2c32f07..a748dbe 100644 --- a/deps.edn +++ b/deps.edn @@ -1,4 +1,6 @@ {:deps {org.clojure/clojure {:mvn/version "1.10.1"} enlive/enlive {:mvn/version "1.1.6"} - selmer/selmer {:mvn/version "1.12.31"}}} + selmer/selmer {:mvn/version "1.12.31"} + org.mozilla/rhino {:mvn/version "1.7.13"} + clj-http/clj-http {:mvn/version "3.12.3"}}} diff --git a/scraped-jobs.edn b/scraped-jobs.edn index 5fc5f0c..b990813 100644 --- a/scraped-jobs.edn +++ b/scraped-jobs.edn @@ -1 +1 @@ -({:title "Pessoa Desenvolvedora de Software Backend Sênior (Clojure)", :url "https://embraer.gupy.io/jobs/1108893?jobBoardSource=gupy_public_page", :location "São José dos Campos", :department "Inovação", :remote true, :type "Talent pool", :name "Embraer"} {:title "Full Stack Developer", :url "https://airtable.com/embed/shrG8DnjAdAOAZm9h/tble1ghQMefhblMVK/viwOzu3raZSmdxK7Z/recGtRyuHlvFhUV0v", :location nil, :department "Engineering", :remote true, :name "Flow Finance"} {:title "Business Security Manager", :url "https://boards.greenhouse.io/nubank/jobs/3400816", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Cloud Security Engineer Specialist", :url "https://boards.greenhouse.io/nubank/jobs/3339732", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Data Engineer", :url "https://boards.greenhouse.io/nubank/jobs/3264442", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Mobile Software Engineer ", :url "https://boards.greenhouse.io/nubank/jobs/1776035", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Offensive Security Engineer Specialist", :url "https://boards.greenhouse.io/nubank/jobs/3410377", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Security Incident Responder SecOps", :url "https://boards.greenhouse.io/nubank/jobs/3382061", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Software Engineer", :url "https://boards.greenhouse.io/nubank/jobs/2569175", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Systems Engineer (SRE/DevOps)", :url "https://boards.greenhouse.io/nubank/jobs/3372800", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Tech Manager", :url "https://boards.greenhouse.io/nubank/jobs/2989044", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Engenheira de Software (vaga focada em mulheres) | Trabalho Remoto", :url "https://pipo-saude.breezy.hr/p/2508984cb6c6-engenheira-de-software-vaga-focada-em-mulheres-trabalho-remoto", :location "%LABEL_POSITION_TYPE_WORLDWIDE%", :department "Engenharia", :type "%LABEL_POSITION_TYPE_FULL_TIME%", :name "Pipo Saúde"} {:title "Pessoa Engenheira de Software (vaga focada em pessoas negras)", :url "https://pipo-saude.breezy.hr/p/1a9152c5e824-pessoa-engenheira-de-software-vaga-focada-em-pessoas-negras", :location "%LABEL_POSITION_TYPE_WORLDWIDE%", :department "Engenharia", :type "%LABEL_POSITION_TYPE_FULL_TIME%", :name "Pipo Saúde"} {:title "Pessoa Engenheira de Software (vaga focada em pessoas trans) | Trabalho Remoto", :url "https://pipo-saude.breezy.hr/p/647061946892-pessoa-engenheira-de-software-vaga-focada-em-pessoas-trans-trabalho-remoto", :location "%LABEL_POSITION_TYPE_WORLDWIDE%", :department "Engenharia", :type "%LABEL_POSITION_TYPE_FULL_TIME%", :name "Pipo Saúde"} {:title "Pessoa Engenheira de Software Sênior", :url "https://pipo-saude.breezy.hr/p/323a55e4c15f-pessoa-engenheira-de-software-senior", :location "%LABEL_POSITION_TYPE_WORLDWIDE%", :department "Engenharia", :type "%LABEL_POSITION_TYPE_FULL_TIME%", :name "Pipo Saúde"}) \ No newline at end of file +({:title "Pessoa Desenvolvedora de Software Backend Sênior (Clojure)", :url "https://embraer.gupy.io/jobs/1108893?jobBoardSource=gupy_public_page", :location "São José dos Campos", :department "Inovação", :remote true, :type "Talent pool", :name "Embraer"} {:title "Full Stack Developer", :url "https://airtable.com/embed/shrG8DnjAdAOAZm9h/tble1ghQMefhblMVK/viwOzu3raZSmdxK7Z/recGtRyuHlvFhUV0v", :location nil, :department "Engineering", :remote true, :name "Flow Finance"} {:title "Business Security Manager", :url "https://boards.greenhouse.io/nubank/jobs/3400816", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Cloud Security Engineer Specialist", :url "https://boards.greenhouse.io/nubank/jobs/3339732", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Data Engineer", :url "https://boards.greenhouse.io/nubank/jobs/3264442", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Mobile Software Engineer ", :url "https://boards.greenhouse.io/nubank/jobs/1776035", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Offensive Security Engineer Specialist", :url "https://boards.greenhouse.io/nubank/jobs/3410377", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Security Incident Responder SecOps", :url "https://boards.greenhouse.io/nubank/jobs/3382061", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Software Engineer", :url "https://boards.greenhouse.io/nubank/jobs/2569175", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Systems Engineer (SRE/DevOps)", :url "https://boards.greenhouse.io/nubank/jobs/3372800", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Tech Manager", :url "https://boards.greenhouse.io/nubank/jobs/2989044", :location "São Paulo", :department "60350", :office_id "58102", :remote false, :name "Nubank"} {:title "Engenheira de Software (vaga focada em mulheres) | Trabalho Remoto", :url "https://pipo-saude.breezy.hr/p/2508984cb6c6-engenheira-de-software-vaga-focada-em-mulheres-trabalho-remoto", :location "Remoto ao redor do mundo", :department "Engenharia", :type "%LABEL_POSITION_TYPE_FULL_TIME%", :remote true, :name "Pipo Saúde"} {:title "Pessoa Engenheira de Software (vaga focada em pessoas negras)", :url "https://pipo-saude.breezy.hr/p/1a9152c5e824-pessoa-engenheira-de-software-vaga-focada-em-pessoas-negras", :location "Remoto ao redor do mundo", :department "Engenharia", :type "%LABEL_POSITION_TYPE_FULL_TIME%", :remote true, :name "Pipo Saúde"} {:title "Pessoa Engenheira de Software (vaga focada em pessoas trans) | Trabalho Remoto", :url "https://pipo-saude.breezy.hr/p/647061946892-pessoa-engenheira-de-software-vaga-focada-em-pessoas-trans-trabalho-remoto", :location "Remoto ao redor do mundo", :department "Engenharia", :type "%LABEL_POSITION_TYPE_FULL_TIME%", :remote true, :name "Pipo Saúde"} {:title "Pessoa Engenheira de Software Sênior", :url "https://pipo-saude.breezy.hr/p/323a55e4c15f-pessoa-engenheira-de-software-senior", :location "Remoto ao redor do mundo", :department "Engenharia", :type "%LABEL_POSITION_TYPE_FULL_TIME%", :remote true, :name "Pipo Saúde"}) \ No newline at end of file diff --git a/src/clojure_empregos_brasil/boards.clj b/src/clojure_empregos_brasil/boards.clj index 6b322f6..3fefd9b 100644 --- a/src/clojure_empregos_brasil/boards.clj +++ b/src/clojure_empregos_brasil/boards.clj @@ -1,6 +1,7 @@ (ns clojure-empregos-brasil.boards (:require [net.cgrand.enlive-html :as html] - [clojure-empregos-brasil.scrap :as scrap])) + [clojure-empregos-brasil.scrap :as scrap] + [clojure-empregos-brasil.breezy :as breezy])) (def gupy {:title [:.title html/text-node] @@ -21,6 +22,14 @@ (def breezy {:title [:h2 html/text-node] :url #(-> % (html/select [:a]) first :attrs :href) - :location [:ul.meta :li.location html/text-node] + :location #(-> % + (html/select [:ul.meta :li.location html/text-node]) + first + breezy/i18n) :department [:ul.meta :li.department html/text-node] - :type [:ul.meta :li.type html/text-node]}) + :type [:ul.meta :li.type html/text-node] + :remote #(-> % + (html/select [:ul.meta :li.location html/text-node]) + (->> first (contains? #{"%LABEL_POSITION_TYPE_REMOTE%" + "%LABEL_POSITION_TYPE_Worldwide%" + "%LABEL_POSITION_TYPE_WORLDWIDE%"})))}) diff --git a/src/clojure_empregos_brasil/breezy.clj b/src/clojure_empregos_brasil/breezy.clj new file mode 100644 index 0000000..06d6171 --- /dev/null +++ b/src/clojure_empregos_brasil/breezy.clj @@ -0,0 +1,89 @@ +(ns clojure-empregos-brasil.breezy + (:require [net.cgrand.enlive-html :as html] + [clj-http.client :as http]) + (:import [org.mozilla.javascript CompilerEnvirons Context Parser Token] + [org.mozilla.javascript.ast NodeVisitor])) + +(def ^:private i18n-map (atom nil)) + +(defn- parse-js + [source uri] + (let [env (new CompilerEnvirons)] + (.setLanguageVersion env Context/VERSION_ES6) + + (-> (Parser. env) + (.parse source uri 0)))) + +(defn- translation-var? + [node] + (let [node (.getTarget node)] + (and (= (.getType node) Token/NAME) + (= (.getIdentifier node) "TRANSLATIONS")))) + +(defn- make-visitor + [target] + (reify NodeVisitor + (visit [this node] + (if (= (.getType node) Token/VAR) + (do + (when-let [node (first (filter translation-var? (.getVariables node)))] + (reset! target (.getInitializer node))) + false) + true)))) + +(defn- find-translation-node + [ast] + (let [translation-node (atom nil) + visitor (make-visitor translation-node)] + (.visitAll ast visitor) + @translation-node)) + +(defn- node->str + [node] + (let [type (.getType node)] + (cond + (= type Token/NAME) (.getIdentifier node) + (= type Token/STRING) (.getValue node) + (= type Token/NUMBER) (.getValue node) + :else nil))) + +(def object-literal->hashmap) + +(defn- element->pair + [element] + (let [left (.getLeft element) + right (.getRight element)] + [(node->str left) (if (= (.getType right) Token/OBJECTLIT) + (object-literal->hashmap right) + (node->str right))])) + +(defn- object-literal->hashmap + [literal] + (if (not= (.getType literal) Token/OBJECTLIT) + nil + (into {} (map element->pair (.getElements literal))))) + +(defn- translate-script-src + [page] + (-> page (html/select [:#translateScript]) first :attrs :src)) + +(defn- fetch-script + [url] + (-> url http/get :body)) + +(defn load-i18n + [page] + (let [translate-script (translate-script-src page)] + (reset! i18n-map + (-> translate-script + fetch-script + (parse-js translate-script) + find-translation-node + object-literal->hashmap + (get "pt-br"))))) + + +(defn i18n + [key] + (get @i18n-map key key)) + diff --git a/src/clojure_empregos_brasil/companies.clj b/src/clojure_empregos_brasil/companies.clj index 7327a8d..b967e44 100644 --- a/src/clojure_empregos_brasil/companies.clj +++ b/src/clojure_empregos_brasil/companies.clj @@ -1,6 +1,7 @@ (ns clojure-empregos-brasil.companies (:require [clojure.string :as string] - [clojure-empregos-brasil.boards :as boards])) + [clojure-empregos-brasil.boards :as boards] + [clojure-empregos-brasil.breezy :as breezy])) (def nubank {:name "Nubank" @@ -9,8 +10,7 @@ :scrap boards/greenhouse :engineer? (comp (partial = "60350") :department) :brazil? (comp (partial = "58102") :office_id) - :clojure? boolean - :enrich identity}) + :clojure? boolean}) (def paygo {:name "PayGo" @@ -41,4 +41,5 @@ :scrap boards/breezy :engineer? #(= (:department %) "Engenharia") :brazil? boolean - :clojure? boolean}) + :clojure? boolean + :pre-html #(do (breezy/load-i18n %) %)}) diff --git a/src/clojure_empregos_brasil/scrap.clj b/src/clojure_empregos_brasil/scrap.clj index 75eb1f5..0c6ba5f 100644 --- a/src/clojure_empregos_brasil/scrap.clj +++ b/src/clojure_empregos_brasil/scrap.clj @@ -43,9 +43,9 @@ sequence." [& companies] (flatten - (for [{:keys [engineer? brazil? clojure? enrich name page] :as company} companies] + (for [{:keys [engineer? brazil? clojure? pre-html name page] :as company} companies] (let [html (html/html-resource (URL. page)) - positions (scrap html + positions (scrap (if (fn? pre-html) (pre-html html) html) (:path company) (:scrap company))] (->> positions