/lhtmlr

A fast Lua HTML Parsing/Searching library written in Rust for Lotus Project

Primary LanguageRustGNU General Public License v2.0GPL-2.0

LHTMLR

A fast Lua HTML Parsing/Searching library written in Rust for Lotus Project

TODO

  • HTML Parsing
  • Generate CSS Selector
    • Element
    • Text
    • Comment
    • Document

Example

local lhtmlr = require("lhtmlr")

local HTML = [[
<!DOCTYPE html>
<html>
  <head>
    <title>My HTML Page</title>
  </head>
  <body>
    <img src="profile.png">
    <h1>Welcome to my HTML page</h1>
  </body>
</html>
]]

-- Generate a CSS selector pattern for **custom** Element in the HTML input that has attributes.
local pattern = lhtmlr.css_selector("<img src=\"profile.png\">") -- Type: String
local results = lhtmlr.html_search(HTML, pattern) -- Type: Table

for _,value in pairs(results) do
    print(value)
end

-- <img src="profile.png">

Installation

$ luarocks install lua-lhtmlr --local