Skip to main content

Auto GET/POST web scraping helper for Python requests.

Project description

CrawlQuest

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/yourusername/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.0.tar.gz (3.7 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.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: crawlquest-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for crawlquest-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1b531d6c35a0c73427e67cbbf4777e0671c1766733e5b3cf231154085c0e9b4a
MD5 f104fb1700b62d4c6a58fd2421d06877
BLAKE2b-256 31fef35eb86d30fcc732ee1333c77dac6c50ea4a1dfa53a91245d4ce18b85f58

See more details on using hashes here.

File details

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

File metadata

  • Download URL: crawlquest-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for crawlquest-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d26c555c619e4ca8da4b79ad6ddf45e43667fd66f9aea07dc6e059c2f6e66e5d
MD5 90655e6884015f2e5d52479ad64a6fe3
BLAKE2b-256 ef4dbc58a76b474ca6ee1117a27ba7e7628a8cc54cf39790ebd7264b8695ac39

See more details on using hashes here.

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