This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-08-03
Channels
- # announcements (5)
- # babashka (7)
- # beginners (119)
- # biff (4)
- # cider (7)
- # clj-kondo (26)
- # cljfx (3)
- # cljs-dev (2)
- # clojure (28)
- # clojure-austin (18)
- # clojure-europe (9)
- # clojure-france (6)
- # clojure-norway (4)
- # clojure-uk (3)
- # clojurescript (6)
- # community-development (1)
- # core-async (4)
- # cursive (9)
- # data-science (12)
- # datomic (13)
- # duct (18)
- # emacs (15)
- # etaoin (5)
- # events (13)
- # honeysql (46)
- # hyperfiddle (9)
- # jackdaw (5)
- # jobs (13)
- # keechma (4)
- # lsp (37)
- # malli (32)
- # nbb (14)
- # off-topic (10)
- # other-languages (2)
- # polylith (4)
- # programming-beginners (3)
- # reagent (27)
- # reitit (1)
- # shadow-cljs (32)
- # sql (11)
- # tools-build (5)
- # tools-deps (3)
- # vim (14)
- # xtdb (11)
(require '[etaoin.api :as e]
'[clojure.java.shell :refer [sh]]
)
;; Start WebDriver for chrome
(def driver (e/chrome)) ;; a Firefox window should appear
;; navigate to wikipedia
(e/go driver "")
(e/wait-visible driver [{:id :FiltroForm}])
(e/fill driver {:id :FiltroRegional} "BH - METROPOLITANA A - 1ª SRE")
(e/click driver {:id :FiltroMunicipio})
(e/click driver {:id :FiltroMunicipio})
(e/fill driver {:id :FiltroMunicipio} "BELO HORIZONTE")
(e/click driver {:id :FiltroCarreira})
(e/fill driver {:id :FiltroCarreira} "PEB - PROFESSOR DE EDUCAÇÃO BÁSICA")
(e/click driver {:id :FiltroCarreira})
(e/click driver {:id :btnFiltro})
(loop []
(doseq [line (range 2 17)]
(let [category (str "table.tabela>tbody>tr:nth-child(" line ") td:nth-child(6)")
action (str "table.tabela>tbody>tr:nth-child(" line ") td:nth-child(8)")]
(when-let [texto (e/get-element-text driver {:css category})]
(when (= "HISTORIA" texto)
(e/click driver {:css category})
(e/click driver {:css action})
(sh "play" "/usr/share/sounds/freedesktop/stereo/complete.oga")))))
(let [next-page "div.next>a"]
(when (e/get-element-text driver {:css next-page})
(e/click driver {:css next-page})
(recur))))
Search for county jobs for wifeHi @U0516053R, happy to try and help once I understand. (maybe you are still editing your question?). What are you trying to achieve? What is happening? And what were you expecting?
I enjoyed the process, babashka + etaoin. very good combination. The css selector worked very well. And it's the first time I can remember I've made a loop recur without variables, perfect for this case when you want to loop (like a ancient goto) based on the existence of next page. Thank you for this project.
Awesome @U0516053R! Thanks so much for sharing your success!