Skip to main content

A simpler interface for scraping with some basic parsing, aes encryption decryption and some logging utils.

Project description

RequestEZ

RequestEZ is a Python library that simplifies web scraping, provides basic parsing utilities, AES encryption/decryption, and some useful logging utilities.

Installation

You can install RequestEZ using pip. Make sure you have Python 3.9 or later installed.

pip install requestez

Usage

1. Basic Web Scraping:

RequestEZ provides a simple interface for making HTTP requests. You can create a session and use it to fetch web pages.

from requestez import Session
session = Session()
response: str = session.get("https://example.com")  # refer to inline documentation for more options
print(response)

2. AES Encryption/Decryption:

You can use RequestEZ to perform AES encryption and decryption of data.

from requestez.encryption import aes_enc, aes_dec

key: bytes = b"your_32_byte_secret_key"
iv: bytes = b"your_16_byte_initialization_vector"
data: str = "your_data_to_encrypt"

encrypted_data: str = aes_enc(key, iv, data)
decrypted_data: str = aes_dec(key, iv, encrypted_data)

print("Encrypted:", encrypted_data)
print("Decrypted:", decrypted_data)

# you need to do from requestez.encryption.unpack import PACKER to find and decrypt p.a.c.k.e.r. encrypted data
# read code to find out more

3. Parsing Utilities:

RequestEZ provides some basic parsing utilities. You can use them to parse HTML, JSON, and XML data.

from requestez.parsers import html, load
html_data = "<html><body><h1>Hello World</h1></body></html>"
json_data = '{"name": "John Doe", "age": 30}'

# Parse HTML data
parsed_html = html(html_data) # returns a BeautifulSoup object

# Parse JSON data
parsed_json = load(json_data) # returns a dict if valid json otherwise returns the string itsef

There are other parsing utilities available as well. Please read the inline documentation for those. some of them are

  • m3u8_master for parsing a M3U8 master playlist
  • m3u8 for parsing M3U8 data > returns m3u8.parse(playlist)
  • reg_replace basically re.sub just don't have to import re
  • secondsToRead for converting seconds to human-readable format like x day(s) x hour(s)...
  • secondsToTime for converting seconds to (DD):HH:MM:SS format
  • stringify for converting a dict to a string with optional escaping
  • load for loading JSON data which can handle escaped json but is iterative to handle escaped json

4. Logging Utilities:

RequestEZ provides some useful and colorful logging utilities. You can use them to log data to a file or to the console.

# it works similar to the logging module but with some extra features
# Logging to a file not supported yet
# Color compatibility depends on the terminal
# Works on windows cmd, powershell, and linux terminal (tested) 
# others not tested
import time
from requestez.helpers import log, set_log_level, pbar
set_log_level("debug")
log("Hello World", color="green" ,log_level="debug") # logs hello world
set_log_level("info") # sets log level to debug
log("Hello World", color="green" ,log_level="info") # logs red hello world to console
log("Hello World", color="red" ,log_level="debug") # logs nothing to console
# Refer to inline documentation for more options


progress_printer = pbar(total=10, prefix='Progress:', suffix='', length=35, color="green", unit="seconds")
for i in range(11):
    time.sleep(1)  # Simulate some work
    progress_printer.update(i)
    # it is equivalent to 
    # progress_printer.update(plus=1) -> this is done by default in the tqdm module
# Refer to inline documentation for more options

the order of level priority is as follows:

  • priority level (alias)
  1. CRITICAL (c)
  2. ERROR (e)
  3. WARNING (w)
  4. INFO (i)
  5. DEBUG (d)

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

requestez-0.1.5.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

requestez-0.1.5-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file requestez-0.1.5.tar.gz.

File metadata

  • Download URL: requestez-0.1.5.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.16

File hashes

Hashes for requestez-0.1.5.tar.gz
Algorithm Hash digest
SHA256 2ec1621c5e5843e45cf3c356d8683a308b7f1be2757d4f152482e93249ac0df7
MD5 c5b7af2e05578f459db7dc6e729879cb
BLAKE2b-256 af66291c0689642bbd200b5b668b359971758037aa99f9aa12382713f61ad883

See more details on using hashes here.

File details

Details for the file requestez-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: requestez-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.9.16

File hashes

Hashes for requestez-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cf4225660a5ae2438f8c3e798c96f1e4abddd8cc09407681e4a2413025682e86
MD5 a442efcddbb17a68509580d0f5ef091e
BLAKE2b-256 b4d0c7e2e429cfb900164af97f377eb883e54bc0ac120b48b6f85d3817bf45c4

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