Skip to content

Simple library for parsing HTML documents inspired by beautifulsoup4

License

Notifications You must be signed in to change notification settings

TelegramXPlus/beautifulparser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Simple library for parsing HTML documents inspired by beautifulsoup4

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages