Skip to content
This repository was archived by the owner on Jul 8, 2018. It is now read-only.

Commit fc1f9ed

Browse files
committed
+alpha script to spider hackage & get available repos
Ignore-this: e7bb8b4921f9c95f5c40fb326dacd0ca darcs-hash:20100314232103-f7719-21066bcc15cb727b7da1c5ca520df30c64119dc9
1 parent 3f8b501 commit fc1f9ed

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

hackage.hs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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]

0 commit comments

Comments
 (0)