Skip to content

Instantly share code, notes, and snippets.

@anekos
Created March 12, 2009 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anekos/78087 to your computer and use it in GitHub Desktop.
Save anekos/78087 to your computer and use it in GitHub Desktop.
美人時計
import System.IO
import Network.URI
import Network.HTTP
import Network.Stream
import Control.Concurrent
padnum n | n < 10 = '0' : show n
| otherwise = show n
filename h m = padnum h ++ padnum m ++ ".jpg"
numURI h m = f $ parseURI $ "http://www.bijint.com/jp/img/photo/" ++ (filename h m)
where f (Just x) = x
makeReq uri = Request uri GET [] ""
getBijin h m = let uri = numURI h m
in do print uri >> hFlush stdout
Right res <- simpleHTTP $ makeReq uri
write res
where write res | (rspCode res) == (2,0,0) = do file <- openBinaryFile (filename h m) WriteMode
hPutStr file $ rspBody res
| otherwise = interval >> getBijin h m
interval = threadDelay (5 * 1000000)
main = sequence_ [getBijin h m >> interval | h <- [0..23], m <- [0..59]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment