Basic bindings for cheerio. Only includes read-only functionality for now.
Install cheerio dependency:
$ npm install --save cheerioInstall this package using spago:
- Add package to your
spago.dhall:
...
dependencies = [ ..., "cheerio" ]
...- Install packages by running:
$ spago installFrom basic example.
Imports:
import Cheerio (Cheerio, find, length)
import Cheerio.Static (loadRoot)Example html:
htmlEx :: String
htmlEx = """
<ul id="fruits">
<li class="apple">Apple</li>
<li class="orange">Orange</li>
<li class="pear">Pear</li>
</ul>
"""Load it and get the root element:
root :: Cheerio
root = loadRoot htmlExUse the query functions:
let fruitCount = root # find "#fruits" # find "li" # length
in log $ "Number of fruits: " <> show fruitCountFor more examples, please take a look at the unit tests. They cover most of the read-only cheerio functions.
If you run into any issues or have suggestions, please open an issue or submit a pull request. Both are welcome!
Be prepared to wait more than a couple of days for a response though :)
MIT