Socket
Socket
Sign inDemoInstall

HTML-Reader

Package Overview
Dependencies
0
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    HTML-Reader

Read HTML data and convert it into python classes.


Maintainers
1

Readme

HTML-Reader

Read HTML data and convert it into python classes.

Installation

From PyPi:

pip install HTML-Reader

From Github Repo:

pip install git+https://github.com/Monkvy/HTML-Reader

Usage

Get elements by class, id, src, etc.

  • Open a HTML-File or create a string with HTML code.
  • Get HTML-Element by calling Element.Get() and insert a keyword.

Example HTML-File "example.html":

<div class="content">
	<h1 class="title">Example title</h1>
	<p>
		Lorem ipsum dolor sit amet, 
		consetetur sadipscing elitr, sed diam
	</p>
</div>

Python Code:

import HTMLReader

with open("example.html", "r") as file:
	raw_html = file.read()
	title = HTMLReader.Element.Get(raw_html, "class=\"title\"")[0]
	
	print(title.content)

Output:

Example title

Get elements by tag

  • Open a HTML-File, created in the example above.
  • Get HTML-Element by calling Element.GetWithTag() and insert a tag.
import HTMLReader

with open("example.html", "r") as file:
	raw_html = file.read()
	title = HTMLReader.Element.GetWithTag(raw_html, "p")[0]
	
	print(title.content)

Output:

Lorem ipsum dolor sit amet, 
consetetur sadipscing elitr, sed diam

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