Created
March 12, 2009 14:24
-
-
Save anekos/78087 to your computer and use it in GitHub Desktop.
美人時計
This file contains 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
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