Skip to content

Commit

Permalink
Changedto a callback function instead of a simple "write string"
Browse files Browse the repository at this point in the history
  • Loading branch information
John Anthony committed Jan 8, 2012
1 parent 3ed0c36 commit 94cc6a7
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Haskell/Scraper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ import Network.Curl.Easy
import Text.Regex.TDFA
import System.Environment ( getArgs )

writeToFile handle string = do
hPutStr handle string

getImage s = do
curl <- initialize
putStr $ "Getting image: " ++ show s
outFile <- openFile (filePath s) WriteMode
setopt curl (CurlWriteFunction $ easyWriter (writeToFile outFile) )
setopt curl (CurlURL s)
hSetBinaryMode outFile True
(_, imageStr) <- curlGetString s []
hPutStr outFile imageStr
perform curl
hClose outFile
putStr " ... Done!\n"
where
Expand Down

0 comments on commit 94cc6a7

Please sign in to comment.