Skip to main content

Auto GET/POST web scraping helper for Python requests.

Project description

CrawlQuest

Test Status Publish Status

Lightweight wrapper around Python requests that automatically chooses between GET and POST based on the presence of a payload.
Perfect for web scraping, automation, and crawling tools where fast and adaptive request behavior is needed.

Features

  • Automatically uses GET if no payload, POST if payload is present
  • Supports returning JSON, HTML, raw bytes
  • Optional requests.Session injection for cookie/session reuse
  • Simple API with built-in error handling
  • Customizable timeout and headers

Installation

pip install crawlquest

Alternatively, install manually

git clone https://github.com/leewr9/crawlquest.git
cd crawlquest
pip install .

Usage

from crawlquest import json, html, raw

# Automatically POSTs (since payload exists)
res = json("https://httpbin.org/post", payload={"key": "value"})

# Automatically GETs (no payload)
html_content = html("https://example.com")

# Raw bytes (e.g., image or file)
binary = raw("https://httpbin.org/image/png")

Using a persistent session (cookie reuse)

import requests
from crawlquest import json

session = requests.Session()
json("https://httpbin.org/cookies/set?mycookie=value", session=session)
res = json("https://httpbin.org/cookies", session=session)

print(res)
# Output: {'cookies': {'mycookie': 'value'}}

API Reference

json(url, payload=None, headers=None, timeout=10.0, session=None) -> dict | None

  • Automatically parses JSON response.
  • Returns None if decoding fails.

html(url, ...) -> str

  • Returns the text (HTML) of the response.
  • Automatically applies apparent_encoding if needed.

raw(url, ...) -> bytes

  • Returns the raw byte content (e.g., for images or binary files).

Error Handling

All internal HTTP calls raise RuntimeError with context on failure

try:
    data = json("https://example.com/api")
except RuntimeError as e:
    print(f"Request failed: {e}")

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

crawlquest-0.1.3.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

crawlquest-0.1.3-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file crawlquest-0.1.3.tar.gz.

File metadata

  • Download URL: crawlquest-0.1.3.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for crawlquest-0.1.3.tar.gz
Algorithm Hash digest
SHA256 674a5cef6d28ec250294ee2069be7be346220c3ca42bf8d6500f7e49c572b3f2
MD5 26d9cdbda05398c23fcbd5f2f1e8c265
BLAKE2b-256 7873abf545eb12a55d2413e817ee34b3e49611735946cf30de2bc4dba1aa8218

See more details on using hashes here.

Provenance

The following attestation bundles were made for crawlquest-0.1.3.tar.gz:

Publisher: publish.yml on leewr9/crawlquest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file crawlquest-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: crawlquest-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for crawlquest-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d7f91c6112eda89edc09a1f9e6109ee637d485d1462b43af6740676b92c1a610
MD5 87bedca227547e5a260b2c16f00a57b8
BLAKE2b-256 d61a8ddcfedf2efadf4cff54a2c8ae253ca5eae78d2149399c9a6531cad947fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for crawlquest-0.1.3-py3-none-any.whl:

Publisher: publish.yml on leewr9/crawlquest

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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