A simple HTML parser that enables search for nodes using CSS selectors
open sourceMITfree
Floki is an Elixir library that parses HTML into a tree of tuples and lets you query it with CSS selectors, then read text, attributes or raw HTML from the matching nodes. By default it uses a patched mochiweb_html parser written in Erlang, which needs no outside dependencies, and it can switch to the faster fast_html (lexbor) or html5ever parsers for large or tricky documents.
Problems it solves
- find elements in an HTML page with CSS selectors from Elixir
- scrape data out of HTML in an Elixir app
- parse an HTML document in Elixir and read text and attributes
Features
- CSS selector queries over parsed HTML
- text, attribute and raw HTML extraction
- pure Erlang parser by default
- optional fast_html and html5ever parsers
Limitations
- The default mochiweb_html parser can be up to 20 times slower than the alternatives on big HTML documents, and differs from the HTML5 specification in some cases.1
