A python library that parses html into a tree structure
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
TreepyParser-1.2.0.tar.gz
(4.3 kB
view details)
File details
Details for the file TreepyParser-1.2.0.tar.gz.
File metadata
- Download URL: TreepyParser-1.2.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
965277ae102ed5235117cd44fd05c6c8ce0f4e1799999b022e602c7e41b79fd2
|
|
| MD5 |
11462b59033b81098011ec8b8a9eca93
|
|
| BLAKE2b-256 |
0532639e70ace531e71d3d6655ba5838ec558af5b6fc741e9c90be1cd3016c59
|