hi people, I have a question about how can I read a html table with etaoin
Hi. Here is function from one of my tests if it helps. It returns seqence of rows.
(defn table-data [driver]
(let [row-els (partition (count (query-all driver "//thead/tr[1]/th"))
(query-all driver "//tbody/tr/td"))
rows (map (fn [row]
(map #(get-element-text-el driver %) row))
row-els)
header (map #(get-element-text-el driver %)
(query-all driver "//thead/tr/th"))]
(->> (conj rows header)
;; remove action col
(map butlast))))
There may be super-duper ways to do this using get-element-text
or other etaoin functions, unfortunately I don't have a ready response in that regard. For me, particularly parsing external web content of questionable validitiy or content, I usually call api/get-source
and parse out all the content I care about with java regular expressions.
you'll want to make sure you use the (?s)
regexp prefix to span newlines 🙂
@dave.tenny cool! I didnt thought about that. This may be a good exercise to practice regexp. I will give it a try
@nenadalm I got 40% right from your example… I will break it down to fully understand it
Thanks ppl, I am new to clojure and FP in general, these guidances are really helpful