Skip to main content

htmltagparse

Pepy Total Downlods

A tool designed to quickly parse HTML tags and elements.

Prerequisites

  • Pip packages:

    • beautifulsoup4==4.*
    • html5lib==1.*
    • requests==2.*
  • Optional packages:

    • timeoutcall==1.*

Usage

Reading Page Titles

Firstly, if you would like to view page info alone, you could use a few functions for this:

import htmltagparse
title = htmltagparse.titleFromUri("https://github.com/")
print(title) # output: GitHub: Let’s build from here · GitHub

metadata = htmltagparse.metadataFromUri("https://github.com/") # meta tags from github

Building Pages

Building Pages via URI

from htmltagparse import build

brave = build.fromUri("https://search.brave.com/")
print(brave.response) #output: (200, 'OK')
print(brave.tags) #list of tags found on the specified page
print(brave.elapsed) #the time taken to create the html page class
print(brave.title) #title of the html page

This is not limited to these values alone; there are more values associated with an html page.

Building Pages via HTML

from htmltagparse import HtmlPage
from requests import get

htmlContent = get("https://duckduckgo.com/").text
ddg = HtmlPage(htmlContent)
print(list(ddg.sources)) #output: ['script']

Searching A Page

With this package, you have the ability to search the html page you have created directly through a function:

from htmltagparse import build
import re

videoId = ""
page = build.fromUri("https://www.youtube.com/watch?v=%s" % videoId)
try:
  #NOTE: the regex function already has re's MULTILINE and DOTALL flags in use
  #get a list of tags to the youtube video via this regex pattern
  videoTags = page.regex(r"\"keywords\":(?P<tags>\[.*?),\"channelId\":").group("tags")
  #converting from string to array
  videoTags = re.findall(r"(?:\"|\')(?P<tag>.*?)(?:\'|\")(?:\,|\])", videoTags)
except:
  videoTags = "no tags found"

print(videoTags)

Another way you could get tags from a Youtube video is with the find function, example:

import htmltagparse

videoId = "" #video id here
yt = htmltagparse.build.fromUri("https://www.youtube.com/watch?v=%s" % videoId)
elTagOpening = yt.find("meta", attrs={"name": "keywords"})[0]
videoKeywords = htmltagparse.getElementAttributeValue(elTagOpening, "content").split(", ")
print(videoKeywords) # tags of the youtube video

Developers

Building to Wheel File

  • cd into root directory of this repository
  • run python3 -m build

Contributions

Must not include:

  • Major changes
  • Breaking code
  • Changes to version number

Metadata

Release files for htmltagparse 3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for htmltagparse 3.1
File Size Uploaded Provenance
htmltagparse-3.1.tar.gz 9.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for htmltagparse 3.1
File Interpreter ABI Platform
htmltagparse-3.1-py3-none-any.whl Python 3 none any Details

Total release size: 19.3 kB

Release files / htmltagparse-3.1.tar.gz

Download URL htmltagparse-3.1.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4f45a0282a0269f285ec8e60be5886421c1f7ae27816e9818f9ec79f71aff5bb
BLAKE2b-256 checksum
How to use checksums
131e35a2844ce4ffeecca03476114fc999cbaa961fdaf0e72b5298f2671b8a5e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.4

Release files / htmltagparse-3.1-py3-none-any.whl

Download URL htmltagparse-3.1-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f80e340c7e8a027a3f1fac0f474949599505b35f70ac1d6679cc9f77671502d
BLAKE2b-256 checksum
How to use checksums
09380649c7481503dc535899071fc2f17b7bd420dfd4b10e6810f05bf226839f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.4

Security for htmltagparse 3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page