Skip to content

Instantly share code, notes, and snippets.

@imjacobclark
Created June 14, 2018 22:03
Show Gist options
  • Save imjacobclark/f45739924f4e3057eccd89cc3b185119 to your computer and use it in GitHub Desktop.
Save imjacobclark/f45739924f4e3057eccd89cc3b185119 to your computer and use it in GitHub Desktop.
module Main where
import Network.HTTP.Conduit
import qualified Data.ByteString.Lazy as L
import Text.Regex.PCRE
findNewsroundLinks :: String -> [String]
findNewsroundLinks = map read . getAllTextMatches . (=~ "href=\"/newsround([^\"#]+)")
bytestringToString :: L.ByteString -> [String]
bytestringToString string = findNewsroundLinks (L.unpack string)
getNewsround :: [String]
getNewsround = simpleHttp "http://www.haskell.org/" >>= bytestringToString
main = print (show (length getNewsround))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment