This repository was archived by the owner on Jul 8, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ import Text.HTML.Download -- (openURL)
2+ import Text.HTML.TagSoup -- (parseTags, Tag(TagOpen))
3+ import Data.List -- (isInfixOf, isPrefixOf)
4+ import Control.Monad -- (liftM,liftM2, zipWithM_)
5+
6+ main :: IO ()
7+ main = do urls <- liftM extractURLs $ openURL " http://hackage.haskell.org/packages/archive/pkg-list.html"
8+ print urls
9+ packages <- mapM openURL urls
10+ print packages
11+ let urls' = concatMap extractRepo packages
12+ mapM_ putStrLn urls'
13+
14+ extractRepo :: String -> [String ]
15+ extractRepo arg = map (\ (TagText x) -> x) $ (extractDarcsRepo soup : extractGitRepo soup)
16+ where soup = parseTags arg
17+
18+ extractDarcsRepo :: [Tag String ] -> Tag String
19+ extractDarcsRepo arg = TagText $ " darcs get " ++ y
20+ where (TagOpen _ ((_,y): [] )) = head $ drop 1 $ dropWhile (\ x -> x /= TagText " darcs get " ) arg
21+
22+ extractGitRepo :: [Tag String ] -> [Tag String ]
23+ extractGitRepo arg = filter (\ x -> case x of
24+ (TagText z) -> if " git clone " `isInfixOf` z then True else False
25+ _ -> False ) arg
26+
27+ extractURLs :: String -> [String ]
28+ extractURLs arg = [" http://hackage.haskell.org" ++ x | TagOpen " a" atts <- (parseTags arg),
29+ (_,x) <- atts, " /package/" `isPrefixOf` x]
You can’t perform that action at this time.
0 commit comments