Add simple parse html
This commit is contained in:
parent
7105cc28d2
commit
e0f75fe5b8
3
Main.hs
3
Main.hs
@ -2,9 +2,10 @@ module Main where
|
|||||||
|
|
||||||
import System.Environment
|
import System.Environment
|
||||||
import Download
|
import Download
|
||||||
|
import ParseHtml
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
args <- getArgs
|
args <- getArgs
|
||||||
htmlResult <- downloadHtmlDef (head args)
|
htmlResult <- downloadHtmlDef (head args)
|
||||||
putStrLn htmlResult
|
printDifferentDef htmlResult
|
||||||
|
17
ParseHtml.hs
Normal file
17
ParseHtml.hs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
module ParseHtml (printDifferentDef) where
|
||||||
|
|
||||||
|
import Text.HTML.TagSoup
|
||||||
|
|
||||||
|
printDifferentDef :: String -> IO ()
|
||||||
|
printDifferentDef x = putStrLn (getDifferentDefMessages x)
|
||||||
|
|
||||||
|
getDifferentDefMessages :: String -> String
|
||||||
|
getDifferentDefMessages x = renderTags (differentDefTags x)
|
||||||
|
|
||||||
|
differentDefTags :: String -> [Tag String]
|
||||||
|
differentDefTags =
|
||||||
|
filter (~== TagText "") . (takeWhile (~/= "<div id=contentbox>"))
|
||||||
|
. (dropWhile (~/= "<div id=vtoolbar>")) . parseTags
|
||||||
|
|
||||||
|
numberOfDef :: [Tag String] -> Int
|
||||||
|
numberOfDef tags = ((length tags) + 1) `div` 3
|
Loading…
Reference in New Issue
Block a user