Skip to main content

simple tools for advanced web related actions

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hyperprotocols-0.0.5.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

hyperprotocols-0.0.5-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file hyperprotocols-0.0.5.tar.gz.

File metadata

  • Download URL: hyperprotocols-0.0.5.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for hyperprotocols-0.0.5.tar.gz
Algorithm Hash digest
SHA256 8e959314456a8ff67f59b944f13e8fcc134b01f9c4b72a2d768498b3f475fb74
MD5 ea76e888b38bac3ce1c73b95ec15b530
BLAKE2b-256 d02b0ec8fa69b305c47f6dfab9c6cbdd4513537ecea5b9d2d17e141d91ff955b

See more details on using hashes here.

File details

Details for the file hyperprotocols-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for hyperprotocols-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 eb1d8d2e832a562588cbd6ff33ce3cd574c8371cbae74b615eaf25eee7059989
MD5 25690ec64dd15382283681d789270d39
BLAKE2b-256 b742fcda9c3a3378c01e6cad3865ee8d5ff185fa0e4a83ddec43abdf3b4f922d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page