New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

markupever

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markupever

The fast, most optimal, and correct HTML & XML parsing library.

0.2.1
PyPI
Maintainers
1

MarkupEver

The fast, most optimal, and correct HTML & XML parsing library

Documentation | Releases | Benchmarks

text image image image python-test

MarkupEver is a modern, fast (high-performance), XML & HTML languages parsing library written in Rust.

KEY FEATURES:

  • 🚀 Fast: Very high performance and fast (thanks to html5ever and selectors).
  • 🔥 Easy: Designed to be easy to use and learn. Completion everywhere.
  • Low-Memory: Written in Rust. Uses low memory. Don't worry about memory leaks. Uses Rust memory allocator.
  • 🧶 Thread-safe: Completely thread-safe.
  • 🎯 Quering: Use your CSS knowledge for selecting elements from a HTML or XML document.

Installation

You can install MarkupEver by using pip:

It's recommended to use virtual environments.

$ pip3 install markupever

Example

Parse

Parsing a HTML content and selecting elements:

import markupever

dom = markupever.parse_file("file.html", markupever.HtmlOptions())
# Or parse a HTML content directly:
# dom = markupever.parse("... content ...", markupever.HtmlOptions())

for element in dom.select("div.section > p:child-nth(1)"):
    print(element.text())

Create DOM

Creating a DOM from zero:

from markupever import dom

dom = dom.TreeDom()
root: dom.Document = dom.root()

root.create_doctype("html")

html = root.create_element("html", {"lang": "en"})
body = html.create_element("body")
body.create_text("Hello Everyone ...")

print(root.serialize())
# <!DOCTYPE html><html lang="en"><body>Hello Everyone ...</body></html>

Keywords

markupever

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts