-
-
Save fycth/233f33b6d4d5bdd163c359c5ffe5fee1 to your computer and use it in GitHub Desktop.
Check HTTP status codes
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
| #!/usr/bin/env stack | |
| -- stack --resolver lts-15.10 script | |
| {-# LANGUAGE OverloadedStrings #-} | |
| {-# LANGUAGE NoImplicitPrelude #-} | |
| import RIO | |
| import Network.HTTP.Simple | |
| import qualified RIO.Text as T | |
| main :: IO () | |
| main = runSimpleApp $ do | |
| text <- readFileUtf8 "foo.txt" | |
| let urls = T.lines text | |
| logInfo "Status Code,URL" | |
| for_ urls $ \url -> do | |
| req <- parseRequest $ T.unpack url | |
| res <- httpNoBody req | |
| logInfo $ display (getResponseStatusCode res) <> "," <> display url |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment