beautifulparser is a (very) simple library for parsing HTML documents inspired by beautifulsoup4
nimble install beautifulparser
import std/htmlparser # to use loadHtml/parseHtml procedures
import beautifulparser
let html = loadHtml("input.html") # or parseHtml("<h1>Your html</h1>")
for i in html.findAllNodes("span", {"class": "my-custom-class"}):
echo i.innerText
You can also use tables instead of arrays of tuples of strings (lol)
import std/[htmlparser, tables]
import beautifulparser
let html = loadHtml("input.html")
for i in html.findAllNodes("span", {"class": "my-custom-class"}.toTable()):
echo i.innerText
import std/htmlparser
import beautifulparser
let html = loadHtml("input.html")
let mySpan = html.findNode("span", {"class", "my-custom-class"})
if mySpan.isSome():
# implement your logic