Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Main where
- import Control.Exception (SomeException, try)
- import Control.Monad (when)
- import Data.ByteString.Char8 (ByteString, unpack)
- import Data.Either (isRight)
- import Network.HTTP.Simple (getResponseBody, httpBS, parseRequest)
- main :: IO ()
- main = do
- let urls = <string of 36 rss feed URLs that I can't paste here>
- mapM_
- ( \url -> do
- putStrLn $ "fetching " ++ url
- res <- try $ fetchUrl url :: IO (Either SomeException ByteString)
- case res of
- Left e -> pure ()
- Right dat -> putStrLn $ "process " ++ show (length (unpack dat) `div` 1024)
- )
- urls
- fetchUrl :: String -> IO ByteString
- fetchUrl url = do
- req <- parseRequest url
- res <- httpBS req >>= pure . getResponseBody
- pure res
Advertisement
Add Comment
Please, Sign In to add comment