Skip to main content

hyperprotocols

Advanced Web Utilities

PyPI version License: MIT

hyperprotocols is a Python package that provides advanced utilities for web scraping, HTML manipulation, and API interaction.

Installation

pip install hyperprotocols

Features

  • HYPERTEXT: Extract and manipulate HTML content into structured data
  • TRANSFERPROTOCOLS: Utilities for API interactions, including payload fuzzing, pagination handling, and ultimate recursion

Usage

HYPERTEXT

Extract and manipulate HTML content:

from hyperprotocols.HYPERTEXT import hypertext

# Fetch and parse HTML content
content = hypertext.fetch("https://example.com")
html = hypertext(content)

# Convert HTML to structured schema
schema = html.Schematize()

'''
Outputs:
{

  "selector": "[document]",

  "class": [],

  "id": "",

  "path": "",

  "content": "Example DomainExample DomainThis domain is for use in illustrative examples in documents. You may use this\n    domain in literature without prior coordination or asking for permission.More information...",

  "count": 1,

  "children": [

    {

      "selector": "html",

      "class": [],

      "id": "",

      "path": "",

      "content": "Example DomainExample DomainThis domain is for use in illustrative examples in documents. You may use this\n    domain in literature without prior coordination or asking for permission.More information...",

      "count": 1,

      "children": [

        {

          "selector": "head",

          "class": [],

          "id": "",

          "path": "html",

          "content": "Example Domain",

          "count": 1,

          "children": [

            {

              "selector": "title",

              "class": [],

              "id": "",

              "path": "html > head",

              "content": "Example Domain",

              "count": 1,

              "children": []

            },

            {

              "selector": "meta",

              "class": [],

              "id": "",

              "path": "html > head",

              "content": "",

              "count": 1,

              "children": []

            },

            {

              "selector": "meta",

              "class": [],

              "id": "",

              "path": "html > head",

              "content": "",

              "count": 1,

              "children": []

            },

            {

              "selector": "meta",

              "class": [],

              "id": "",

              "path": "html > head",

              "content": "",

              "count": 1,

              "children": []

            },

            {

              "selector": "style",

              "class": [],

              "id": "",

              "path": "html > head",

              "content": "body {\n        background-color: #f0f0f2;\n        margin: 0;\n        padding: 0;\n        font-family: -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", \"Open Sans\", \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n        \n    }\n    div {\n        width: 600px;\n        margin: 5em auto;\n        padding: 2em;\n        background-color: #fdfdff;\n        border-radius: 0.5em;\n        box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);\n    }\n    a:link, a:visited {\n        color: #38488f;\n        text-decoration: none;\n    }\n    @media (max-width: 700px) {\n        div {\n            margin: 0 auto;\n            width: auto;\n        }\n    }",

              "count": 1,

              "children": []

            }

          ]

        },

        {

          "selector": "body",

          "class": [],

          "id": "",

          "path": "html",

          "content": "Example DomainThis domain is for use in illustrative examples in documents. You may use this\n    domain in literature without prior coordination or asking for permission.More information...",

          "count": 1,

          "children": [

            {

              "selector": "div",

              "class": [],

              "id": "",

              "path": "html > body",

              "content": "Example DomainThis domain is for use in illustrative examples in documents. You may use this\n    domain in literature without prior coordination or asking for permission.More information...",

              "count": 1,

              "children": [

                {

                  "selector": "h1",

                  "class": [],

                  "id": "",

                  "path": "html > body > div",

                  "content": "Example Domain",

                  "count": 1,

                  "children": []

                },

                {

                  "selector": "p",

                  "class": [],

                  "id": "",

                  "path": "html > body > div",

                  "content": "This domain is for use in illustrative examples in documents. You may use this\n    domain in literature without prior coordination or asking for permission.",

                  "count": 1,

                  "children": []

                },

                {

                  "selector": "p",

                  "class": [],

                  "id": "",

                  "path": "html > body > div",

                  "content": "More information...",

                  "count": 1,

                  "children": [

                    {

                      "selector": "a",

                      "class": [],

                      "id": "",

                      "path": "html > body > div > p",

                      "content": "More information...",

                      "count": 1,

                      "children": [],

                      "urls": {

                        "href": "https://www.iana.org/domains/example"

                      }

                    }

                  ]

                }

              ]

            }

          ]

        }

      ]

    }

  ]

}
'''

TRANSFERPROTOCOLS

Fuzz API payloads and handle paginated requests:

from hyperprotocols.TRANSFERPROTOCOLS import PayloadFuzzer, recursively
import requests


payload = {
    'keywords': '',
    'brands': 'gucci',
    'categories': 'shirts',
    'page': 1
}

# Handle paginated API requests
@recursively(pkwarg='payload', paginator='page', breakat=50)
def fetch(payload):
	url = "http://example.com"
	with PayloadFuzzer(payload, fuzzable=['keywords', 'brands', 'categories']) as variations:
	    for variant in variations:
		    response = requests.get(url, variation)
		    # Your request processing logic here
		    pass

'''
fuzzed variations:
    {'keywords': 'gucci', 'brands': '', 'categories': 'shirts', 'page': 1}
    > brand swapped into a keyword
    > > with recursively:
    > > > [{'keywords': 'gucci', 'brands': '', 'categories': 'shirts', 'page': 1}, {'keywords': 'gucci', 'brands': '', 'categories': 'shirts', 'page': 2}, ...{'keywords': 'gucci', 'brands': '', 'categories': 'shirts', 'page': 50}]
    {'keywords': 'shirts', 'brands': 'gucci', 'categories': '', 'page': 1}
    > category swapped into a keyword
    > > with recursively:
    > > > [{'keywords': 'shirts', 'brands': 'gucci', 'categories': '', 'page': 1}, {'keywords': 'shirts', 'brands': 'gucci', 'categories': '', 'page': 2}, ...{'keywords': 'shirts', 'brands': 'gucci', 'categories': '', 'page': 50}]
    {'keywords': 'gucci shirts', 'brands': '', 'categories': '', 'page': 1}
    > brand and category swapped into a keyword
    > > with recursively:
    > > > [{'keywords': 'gucci shirts', 'brands': '', 'categories': '', 'page': 1}, {'keywords': 'gucci shirts', 'brands': '', 'categories': '', 'page': 2}, ... {'keywords': 'gucci shirts', 'brands': '', 'categories': '', 'page': 50}]
'''

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for hyperprotocols 0.0.5

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

Source distribution (sdist)

Source distribution for hyperprotocols 0.0.5
File Size Uploaded
hyperprotocols-0.0.5.tar.gz 7.8 kB Details

Built distribution (wheel)

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

Total release size: 16.0 kB

Release files / hyperprotocols-0.0.5.tar.gz

Download URL hyperprotocols-0.0.5.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8e959314456a8ff67f59b944f13e8fcc134b01f9c4b72a2d768498b3f475fb74
BLAKE2b-256 checksum
How to use checksums
d02b0ec8fa69b305c47f6dfab9c6cbdd4513537ecea5b9d2d17e141d91ff955b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Release files / hyperprotocols-0.0.5-py3-none-any.whl

Download URL hyperprotocols-0.0.5-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb1d8d2e832a562588cbd6ff33ce3cd574c8371cbae74b615eaf25eee7059989
BLAKE2b-256 checksum
How to use checksums
b742fcda9c3a3378c01e6cad3865ee8d5ff185fa0e4a83ddec43abdf3b4f922d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

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