Skills.purs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. module LinkedIn.Page.Skills where
  2. import Prelude
  3. import Data.Foldable (class Foldable, foldMap, foldlDefault, foldrDefault)
  4. import Data.Generic.Rep (class Generic)
  5. import Data.List.Types (NonEmptyList)
  6. import Data.Show.Generic (genericShow)
  7. import Data.Traversable (class Traversable, sequence, traverse, traverseDefault)
  8. import LinkedIn.Extractible (class Extractible)
  9. import LinkedIn.Profile.Skill (Skill)
  10. import LinkedIn.Profile.Skill as PS
  11. import LinkedIn.QueryRunner (subQueryMany)
  12. import LinkedIn.UI.Components.ArtDecoTab (ArtDecoTabElement, queryArtDecoTab)
  13. data SkillsPage a = SkillsPage (NonEmptyList (ArtDecoTabElement a))
  14. derive instance Generic (SkillsPage a) _
  15. derive instance Eq a => Eq (SkillsPage a)
  16. instance Show a => Show (SkillsPage a) where
  17. show = genericShow
  18. derive instance Functor SkillsPage
  19. instance Foldable SkillsPage where
  20. foldMap f (SkillsPage tabs) = foldMap (foldMap f) tabs
  21. foldl = \x -> foldlDefault x
  22. foldr = \x -> foldrDefault x
  23. instance Traversable SkillsPage where
  24. sequence (SkillsPage tabs) = ado
  25. ts <- sequence (map sequence tabs)
  26. in SkillsPage ts
  27. traverse = \x -> traverseDefault x
  28. instance Extractible SkillsPage (NonEmptyList Skill) where
  29. query n = do
  30. tabs <- subQueryMany queryArtDecoTab "div.artdeco-tabs > div > div > div > div > ul > li" n
  31. pure $ SkillsPage tabs
  32. extract (SkillsPage tabs) = traverse PS.fromUI tabs