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

Uploaded Python 3

File details

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

File metadata

  • Download URL: crawlquest-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 227b71f514aebf95194347a254fb6d31bbe25650a47a4c90fd99673802e119ea
MD5 fd46ad982ab6ddca4c3705bfd7587f43
BLAKE2b-256 5fa1db3977561933ed25f19a9f94a51fc16838554ee9b48d18422674909ab2c4

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: crawlquest-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a0c05ff22a16ddc313d240a7f7c874552b738f75a75350217ed412ed676befbb
MD5 500e5288e65a2af826c68f96c7e9158f
BLAKE2b-256 d2e95eeb1d9f57a18629d650ded287a0bbce00d8fa43348ef08eb7fae5784159

See more details on using hashes here.

Provenance

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