purescript-cheerio/examples/Basic.purs

26 lines
501 B
Haskell
Raw Normal View History

2018-01-16 04:35:48 +00:00
module Basic where
import Prelude
import Cheerio (Cheerio, find, length)
import Cheerio.Static (loadRoot)
2020-04-17 17:23:07 +00:00
import Effect (Effect)
import Effect.Console (log)
2018-01-16 04:35:48 +00:00
htmlEx :: String
htmlEx = """
<ul id="fruits">
<li class="apple">Apple</li>
<li class="orange">Orange</li>
<li class="pear">Pear</li>
</ul>
"""
root :: Cheerio
root = loadRoot htmlEx
2020-04-17 17:23:07 +00:00
main :: Effect Unit
main =
let fruitCount = root # find "#fruits" # find "li" # length
2018-01-16 04:35:48 +00:00
in log $ "Number of fruits: " <> show fruitCount