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.2.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.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: crawlquest-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 1e09399c5abccc3290b63c1bc646a81af5ce4e2ad7aff185cc6569a574f70563
MD5 f646c9b7fd9b236135045e309948b67c
BLAKE2b-256 83993bef6b36307de47da899ed0885841c3a0c84889309e113de031832d6f0ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for crawlquest-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: crawlquest-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 083d94308a592b619413edbfeb7c426c368fed05ebee92909a7e59f0fc609803
MD5 797dc76d2084f44c7c54d4632e1f1586
BLAKE2b-256 a8c44e6aa7d40d4254e1d2dc31705c1ddab7a0d77041de2f4840c12ea4b47e1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for crawlquest-0.1.2-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