Hello everyone,
I'm thrilled to share the release of
RingHTML—a powerful new Ring library for parsing and manipulating HTML documents!
Powered by the blazing-fast Lexbor engine, RingHTML brings high-performance scraping and DOM manipulation to Ring. It allows you to navigate the DOM tree, extract data, and build HTML programmatically using a simple and intuitive API.
Key Features:- High-Performance: Built on top of Lexbor, making it one of the fastest HTML5 parsers available.
- CSS Selectors: Full support for `#id`, `.class`, `tag`, `parent child`, and complex selectors.
- DOM Manipulation: Create, modify, insert, and remove nodes programmatically.
- Navigation: Easily traverse parents, children, siblings, and specific elements.
- Unicode Support: Full support for international characters and multilingual content.
Use Cases:
RingHTML is designed to help you with a variety of tasks:
- Web Scraping: Download web pages and easily extract data like prices, headlines, or links using CSS selectors.
- Data Extraction: Parse complex HTML reports or logs to convert them into structured data (Lists/Objects).
- HTML Generation: Programmatically build valid HTML reports or email templates without messy string concatenation.
- Content Sanitization: Load user-submitted HTML and strip out unwanted tags or attributes before saving.
Code Example:Parsing HTML and finding elements is straightforward:
load "html.ring"
# Parse an HTML string
doc = new HTML('
<div class="content">
<h1>Welcome to RingHTML!</h1>
<ul class="links">
<li><a href="/docs">Docs</a></li>
<li><a href="/examples">Examples</a></li>
</ul>
</div>
')
# Find elements using CSS selectors
title = doc.find("h1")[1]
? "Title: " + title.text()
# Extract all links
links = doc.find("ul.links a")
for link in links
? "Link: " + link.text() + " -> " + link.attr("href")
next
InstallationInstall easily via
RingPM:
ringpm install ring-html from ysdragon
Learn MoreContributions are welcome!Have ideas or found a bug? Please open an issue or submit a pull request on GitHub.
Your feedback is greatly appreciated!Hope you find RingHTML useful!
Best regards,
Youssef