Created
June 14, 2018 22:03
-
-
Save imjacobclark/f45739924f4e3057eccd89cc3b185119 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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