etaoin

bartuka 2018-08-04T18:00:12.000079Z

hi people, I have a question about how can I read a html table with etaoin

nenadalm 2018-08-06T05:13:34.000151Z

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))))

👍 1
❤️ 1
jdt 2018-08-06T14:32:31.000229Z

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.

jdt 2018-08-06T14:33:56.000390Z

you'll want to make sure you use the (?s) regexp prefix to span newlines 🙂

bartuka 2018-08-07T01:56:26.000123Z

@dave.tenny cool! I didnt thought about that. This may be a good exercise to practice regexp. I will give it a try

bartuka 2018-08-07T01:57:55.000082Z

@nenadalm I got 40% right from your example… I will break it down to fully understand it

bartuka 2018-08-07T01:58:17.000095Z

Thanks ppl, I am new to clojure and FP in general, these guidances are really helpful