Lua Htmlparser

screenshot of Lua Htmlparser

An HTML parser for lua.

Overview

Htmlparser is a powerful tool designed for parsing HTML documents and snippets into a structured tree of elements. Utilizing Lua, this library is a go-to for developers who aim to manipulate and analyze HTML content easily. With its capability to support various selectors and return specific elements, it enhances the way we interact with HTML data, making it efficient and straightforward.

Whether you are a seasoned programmer or just starting with Lua, Htmlparser provides an intuitive interface to handle HTML parsing. From its dependency on Lua 5.1-5.4 or LuaJIT to the ability to run extensive queries, this tool has a modern approach to dealing with structured content.

Features

  • Selector Support: Utilizes a subset of jQuery's selectors, allowing familiar syntax for querying elements like classes, IDs, and attributes.
  • Tree Structure: Parses HTML into a tree of elements, where you can easily navigate and manipulate the hierarchy of content.
  • Custom Loop Limit: Set a loop-limit value to control the parse deepness, with a default of 1000 to optimize performance.
  • Global Variable Support: Offers a global variable htmlparser_looplimit which can be used to influence loop depth across multiple parser instances.
  • Element Accessors: Each parsed element includes accessors like .name, .attributes, and .id to retrieve necessary information directly.
  • Combinable Selectors: Allows combining selectors for complex queries, facilitating precise targeting of elements within the parsed structure.
  • Flexible Input: Accepts both complete HTML documents and valid snippets, providing flexibility based on your parsing needs.
  • Test Ready: Comes packaged with lunitx, making it easy to conduct unit tests and ensure your parsing logic works correctly.