Simple Haskell Daemon for Setting Wallpapers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

33 lines
735 B

{-# LANGUAGE OverloadedStrings #-}
module Download
(
getImgurGallery
,filterTags
) where
import Network.Wreq
-- Operators such as (&) and (.~).
import Control.Lens
import Control.Monad
import Control.Monad.IO.Class
import Control.Applicative
import Data.Maybe
-- Conversion of Haskell values to JSON.
import Data.Aeson (toJSON)
-- Easy traversal of JSON data.
import Data.Aeson.Lens (key, nth)
import Text.HTML.TagSoup
import Text.HTML.TagSoup.Match
getImgurGallery identity = do
r <- get ("https://imgur.com/gallery/" ++ identity)
let tags = parseTags <$> r ^? responseBody
return $ maybe [] id tags
filterTags tags =
mapM_ print [ t | t <- tags,
tagOpen (\x -> x == "a") (const True) t]