This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-11-08
Channels
- # babashka (18)
- # beginners (35)
- # biff (15)
- # cider (24)
- # clj-commons (26)
- # clj-kondo (12)
- # clojure (18)
- # clojure-austin (1)
- # clojure-dev (2)
- # clojure-europe (15)
- # clojure-losangeles (1)
- # clojure-nl (1)
- # clojure-norway (88)
- # clojure-seattle (2)
- # clojure-spec (14)
- # clojure-uk (27)
- # clojuredesign-podcast (5)
- # clojurescript (25)
- # cursive (3)
- # datahike (26)
- # datalevin (13)
- # datomic (39)
- # etaoin (19)
- # events (1)
- # fulcro (12)
- # graphql (1)
- # hyperfiddle (40)
- # introduce-yourself (3)
- # joyride (8)
- # lsp (53)
- # missionary (7)
- # nyc (1)
- # off-topic (31)
- # overtone (10)
- # reitit (6)
- # shadow-cljs (9)
- # slack-help (9)
- # thejaloniki (1)
- # tools-deps (12)
Hey, I'm using etaoin to do some scraping, is there any way that I can get the text of a the tooltip caused by an active element? Such as the attached media where I want "Tuesday, November 7, 2023 at 7:19 PM" I tried to use OCR but the screenshot quality from etaoin is too low and I haven't found a way to zoom in the view. Any help with either approaches?
Hi @U03QTHYKXK7 do you have an example public web page? What web browser are you using?
Yes this https://www.facebook.com/Cognitect/posts/pfbid0oWQuewGELmYMLiVELC6e93iyfZZcwHYT3xVSeLwRX7j24WNPi9VfGkJ4HjgpbtMUl shows it. By hovering over "July 17, 2018" by mouse or getting there by invoking
(e/fill-active driver
(k/chord k/tab))
until you get thereOh, I don't have a Facebook account and have no plans to ever have one. Would you happen to have another example?
This shouldn't require a Facebook account, I can open it with Etaoin and clear the login prompt, let me supply a minimal example
(def driver (e/firefox))
(e/go driver "")
;; Remove the login prompt
(e/click driver
[{:css ".xc9qbxq > i:nth-child(1)"}])
;; Tab to the date
(repeatedly 8
(fn []
(e/fill-active driver
(k/chord k/tab))))
@UE21H2HHD I'm sipping my second coffee so all good, thanks!
Slack has something similar, when I inspect element I find a data-ts
attribute with a unix timestamp as its value but I am unable to find a similar thing in the FB one. They also both show an event
button in the Firefox Inspector.
@U03QTHYKXK7, it is a bit tricky because the DOM is manipulated on hover.
I fiddled with the browser inspector and saw the parent element dynamically gets an aria-describedy
attribute on link hover, this, in turn, seems to point to an element that has the full date text.
Here's what I tacked onto the end of your example above:
(let [parent-el (e/query driver :active "..")
describe-elem-id (e/get-element-attr-el driver parent-el "aria-describedby") ]
(e/get-element-text driver {:id describe-elem-id}))
;; => "Tuesday, July 17, 2018 at 10:47 AM"
Does that work for you?Yes this works for me!
Didn't think to monitor the DOM as I hover over it, I'll try to learn to do this and add it to my toolbelt, thank you for your time and help
No worries about the local time zone that can be fixed after parsing, the big thing is learn here is to work with a dynamic DOM
I have one question, what does the syntax ".."
mean here? Is it a sort of catch-all classes?
It means parent. So (e/query driver :active "..")
asks for the parent element of the current active element.
I see and I did some googling and this looks it comes form an https://stackoverflow.com/questions/28237694/xpath-get-parent-node-from-child-nodesyntax, am I correct?
Relevant etaoin docs are https://cljdoc.org/d/etaoin/etaoin/1.0.40/doc/user-guide#_simple_queries_xpath_css, which points to these docs on https://www.w3schools.com/xml/xpath_syntax.asp.