|
|
@@ -1,14 +1,17 @@
|
|
|
module LinkedIn.ArtDecoCardAlt where
|
|
|
|
|
|
+import Control.Monad.Except.Trans
|
|
|
import Prelude
|
|
|
|
|
|
-import Data.Either (Either(..), note)
|
|
|
+import Control.Monad.Writer (Writer, tell)
|
|
|
+import Data.Either (Either(..), hush, note)
|
|
|
import Data.Generic.Rep (class Generic)
|
|
|
import Data.List (List)
|
|
|
import Data.List.Types (NonEmptyList)
|
|
|
import Data.Maybe (Maybe)
|
|
|
import Data.Show.Generic (genericShow)
|
|
|
import Effect (Effect)
|
|
|
+import Effect.Class.Console (log, logShow)
|
|
|
import LinkedIn (DetachedNode)
|
|
|
import LinkedIn.ArtDeco (ArtDecoPvsEntity, parseArtDecoPvsEntity)
|
|
|
import LinkedIn.ArtDeco as AD
|
|
|
@@ -46,25 +49,13 @@ instance Functor ArtDecoCardAltElement where
|
|
|
map f (ArtDecoCardAltElement {pvs_entity}) =
|
|
|
ArtDecoCardAltElement ({pvs_entity: map f pvs_entity})
|
|
|
|
|
|
-queryArtDecoCenterHeaderAlt :: Node → Effect (Either QueryError (ArtDecoCenterHeaderAlt Node))
|
|
|
-queryArtDecoCenterHeaderAlt n = do
|
|
|
- bold <- runOne ":scope div.t-bold > span[aria-hidden=true]" n
|
|
|
-
|
|
|
- pure $ ado
|
|
|
- b <- bold
|
|
|
- in ArtDecoCenterHeaderAlt {bold: b}
|
|
|
-
|
|
|
queryArtDecoCardAlt :: Node → Effect (Either QueryError (ArtDecoCardAltElement Node))
|
|
|
queryArtDecoCardAlt n = do
|
|
|
- pvs <- runOne ":scope div.pvs-entity--padded" n
|
|
|
-
|
|
|
- case pvs of
|
|
|
- Left l -> pure $ Left l
|
|
|
- Right p -> do
|
|
|
- header <- queryArtDecoCenterHeaderAlt p
|
|
|
- pure $ ado
|
|
|
- h <- header
|
|
|
- in ArtDecoCardAltElement {pvs_entity: h}
|
|
|
+ eitherResult <- runExceptT do
|
|
|
+ pvs <- ExceptT $ runOne ":scope div.pvs-entity--padded" n
|
|
|
+ bold <- ExceptT $ runOne ":scope div.t-bold > span[aria-hidden=true]" pvs
|
|
|
+ pure $ ArtDecoCardAltElement { pvs_entity: ArtDecoCenterHeaderAlt {bold} }
|
|
|
+ pure eitherResult
|
|
|
|
|
|
runOne ∷ String → Node → Effect (Either QueryError Node)
|
|
|
runOne selector node = do
|