Skip to main content

A simple wrapper for the requests package

Project description

requestwrapper

A simple wrapper for the Python requests package

Motivation

Common use cases when dealing with requests are:

  • handling response errors
  • repeating a request until succesfull response
  • executing multiple requests
  • saving response (html, pdf) to disk

Requestwrapper implements simple methods to perform such tasks without having to write your own code.

Features

  • Parameterize HTTP method using the method-argument
  • Handle HTTP errors (status_code>299) by returning the raw response instead of json
  • Retry failed requests n-times
  • Print request-response to console
  • Save response content to disk

Prerequisites

  1. the requests module (https://pypi.org/project/requests/)

Installing

Hosted on PyPI: (https://pypi.org/project/requestwrapper/) With pip: pip install requestwrapper

Usage

import requestwrapper.Request
#initialize the Request object
Request0=requestwrapper.Request.Request()

# workhorse function: send_request
res=Request0.send_request(url='https://nu.nl',method='GET')

# save response content to disk
Request0.save_response('nu.txt')

Examples

TODO

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

requestwrapper-0.0.5.tar.gz (15.6 kB view hashes)

Uploaded Source

Built Distribution

requestwrapper-0.0.5-py3-none-any.whl (5.9 kB view hashes)

Uploaded Python 3

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