-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-- images
-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
downloadImages base stringHTML
    = do let imgTags =  [ fromAttrib "src" tag
                        | tag <- parseTags stringHTML
                        , tagOpen (=="img") (anyAttrName (== "src")) tag
                        ]
             imgSRCs = nub imgTags  -- elimina los repetidos
             --html = parseTags stringHTML
             --imgTags = map (fromAttrib "src") $ filter (tagOpen (=="img") (anyAttrName (=="src"))) html
             --imgSRCs = Set.toList $ Set.fromList imgTags    -- elimina los repetidos
             imgfuns = map getImageFunctionNameType imgSRCs
         mapM_ downloadprocess imgfuns
    where downloadprocess (url,name,fload,fsave)
                = do img <- download base url
                     gdimg <- fload img
                     tmpDir <- retrieveTempDir
                     let path = tmpDir </> name
                     fsave path gdimg
                     putStrLn $ "image saved at " ++ path
downloadImages base stringHTML
    = do let imgTags =  [ fromAttrib "src" tag
                        | tag <- parseTags stringHTML
                        , tagOpen (=="img") (anyAttrName (== "src")) tag
                        ]
             imgSRCs = nub imgTags  -- elimina los repetidos
             --html = parseTags stringHTML
             --imgTags = map (fromAttrib "src") $ filter (tagOpen (=="img") (anyAttrName (=="src"))) html
             --imgSRCs = Set.toList $ Set.fromList imgTags    -- elimina los repetidos
             imgfuns = map getImageFunctionNameType imgSRCs
         mapM_ downloadprocess imgfuns
    where downloadprocess (url,name,fload,fsave)
                = do img <- download base url
                     gdimg <- fload img
                     tmpDir <- retrieveTempDir
                     let path = tmpDir </> name
                     fsave path gdimg
                     putStrLn $ "image saved at " ++ path
downloadImages base stringHTML
    = do let imgTags =  [ fromAttrib "src" tag
                        | tag <- parseTags stringHTML
                        , tagOpen (=="img") (anyAttrName (== "src")) tag
                        ]
             imgSRCs = nub imgTags  -- elimina los repetidos
             --html = parseTags stringHTML
             --imgTags = map (fromAttrib "src") $ filter (tagOpen (=="img") (anyAttrName (=="src"))) html
             --imgSRCs = Set.toList $ Set.fromList imgTags    -- elimina los repetidos
             imgfuns = map getImageFunctionNameType imgSRCs
         mapM_ downloadprocess imgfuns
    where downloadprocess (url,name,fload,fsave)
                = do img <- download base url
                     gdimg <- fload img
                     tmpDir <- retrieveTempDir
                     let path = tmpDir </> name
                     fsave path gdimg
                     putStrLn $ "image saved at " ++ path