No description
Find a file
2025-08-29 19:12:47 +02:00
.github/workflows add workflows and tests 2024-09-09 02:55:24 +02:00
src refractor code and optimize loop 2025-08-29 19:12:28 +02:00
tests Update test.nim 2024-10-29 01:30:56 +01:00
.gitattributes Initial commit 2023-07-07 14:17:55 +02:00
.gitignore Initial commit 2023-07-07 14:17:55 +02:00
beautifulparser.nimble Update beautifulparser.nimble 2025-08-29 19:12:47 +02:00
LICENSE Initial commit 2023-07-07 14:17:55 +02:00
README.md Update README.md 2024-09-09 17:14:30 +02:00

beautifulparser

Test

beautifulparser is a (very) simple library for parsing HTML documents inspired by beautifulsoup4

Getting Started

nimble install beautifulparser

Usage

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

Using tables

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

Get the first element

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