Floki - search inside HTML documents

Build Status

Floki is useful to search inside HTML documents using query selectors (like jQuery). Under the hood, it uses the Mochiweb HTML parser.

This version works with simple CSS selectors (without nesting or group). List of selectors:

API

To parse a HTML document, try:

html = """
<html>
<body>
<div class="example"></div>
</body>
</html>
"""
Floki.parse(html)
# => {"html", [], [{"body", [], [{"div", [{"class", "example"}], []}]}]}

To find elements with the class example, try:

Floki.find(html, ".example")
# => [{"div", [{"class", "example"}], []}]

To fetch some attribute from elements, try:

Floki.attribute(html, ".example", "class") # href or src are good possibilities to fetch links
# => ["example"]

You can also get attributes from elements that you already have:

Floki.find(html, ".example")
|> Floki.attribute("class")
# => ["example"]

License

Floki is under MIT license. Check the LICENSE file for more details.