Socket
Socket
Sign inDemoInstall

TreepyParser

Package Overview
Dependencies
0
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    TreepyParser

A python library that parses html into a tree structure


Maintainers
1

Readme

TreepyParser

TreepyParser is a python library that parses html into a tree structure

Installation

Use the following command to install

pip install TreepyParser

How to use

import TreepyParser

#pass string containing html
parser.parse(html) #returns html tree

The tree returned is a node representing the element that contains all other elements

Nodes have following methods and variables

node.tag #string representing element e.g. div, p, table
node.get_attribute(key) #returns attribute value, e.g. href => www.example.com
node.add_node(n) #adds node n to node
node.insert_node(n, pos) #inserts node n at position pos of node, previous node at pos will be a child of node n
node.remove_node(pos, remove_subtree) #removes node at pos, if remove_subtree is false children of the removed node will be added to node
node.find(tag="", **kwargs) #returns list of all matches in subtree, kwargs represent attributes
node.nodes_in_subtree() #returns amount of nodes (root excluded) in the subtree

License

MIT

Keywords

FAQs


Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc