All Projects → dcoles → Pycurl Requests

dcoles / Pycurl Requests

Licence: mit
A Requests-compatible interface for PycURL.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pycurl Requests

Requests
A simple, yet elegant, HTTP library.
Stars: ✭ 46,558 (+202326.09%)
Mutual labels:  requests, python-requests, client
Geolocator-2
Learn how to find and work with locations in Django, the Yelp API, and Google Maps api.
Stars: ✭ 24 (+4.35%)
Mutual labels:  requests, python-requests
requests-cloudkit
Apple CloudKit Python library.
Stars: ✭ 60 (+160.87%)
Mutual labels:  requests, python-requests
Php Curl Class
PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs
Stars: ✭ 2,903 (+12521.74%)
Mutual labels:  requests, client
Requests3
Requests 3.0, for Humans and Machines, alike. 🤖
Stars: ✭ 813 (+3434.78%)
Mutual labels:  requests, python-requests
Proxy requests
a class that uses scraped proxies to make http GET/POST requests (Python requests)
Stars: ✭ 357 (+1452.17%)
Mutual labels:  requests, python-requests
Githubv4
Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql).
Stars: ✭ 760 (+3204.35%)
Mutual labels:  client
Wikipedia Frequency Lookup
Simple script written in Python to get the 20 words with highest frequency in an English Wikipedia article
Stars: ✭ 16 (-30.43%)
Mutual labels:  requests
Httpotion
(soft-deprecated) HTTP client for Elixir (use Tesla please)
Stars: ✭ 723 (+3043.48%)
Mutual labels:  client
Heliport
Intel Wi-Fi Client for itlwm
Stars: ✭ 701 (+2947.83%)
Mutual labels:  client
Guzzlette
🌀 Guzzle integration into Nette Framework (@nette)
Stars: ✭ 19 (-17.39%)
Mutual labels:  client
Khttp Android
Kotlin HTTP request library for Android, adapted from @jkcclemens/khttp.
Stars: ✭ 18 (-21.74%)
Mutual labels:  requests
Ws Promise Client
PROJECT MOVED: https://github.com/kdex/ws-promise
Stars: ✭ 6 (-73.91%)
Mutual labels:  client
Parity Ethereum
The fast, light, and robust client for Ethereum-like networks.
Stars: ✭ 6,499 (+28156.52%)
Mutual labels:  client
Teacup nats
Teacup based NATS client for Erlang
Stars: ✭ 16 (-30.43%)
Mutual labels:  client
Toolbelt
A toolbelt of useful classes and functions to be used with python-requests
Stars: ✭ 748 (+3152.17%)
Mutual labels:  python-requests
Jackan
Java client to access CKAN repositories
Stars: ✭ 18 (-21.74%)
Mutual labels:  client
Simple tensorflow serving
Generic and easy-to-use serving service for machine learning models
Stars: ✭ 718 (+3021.74%)
Mutual labels:  client
Openerp Proxy
Provides interface similar to Odoo / OpenERP internal code to perform operations on Odoo / OpenERP objects remotely using XML-RPC or JSON-RPC behind.
Stars: ✭ 17 (-26.09%)
Mutual labels:  client
Uplink
A Declarative HTTP Client for Python
Stars: ✭ 824 (+3482.61%)
Mutual labels:  requests

PycURL Requests <pycurl://☤>

PycURL Requests is a Requests-compatible interface for PycURL.

Requirements

Installation

Latest release via pip:

pip install pycurl-requests [--user]

via Git:

git clone https://github.com/dcoles/pycurl-requests.git; cd pycurl-requests
python3 setup.py install [--user]

Quick-start

>>> import pycurl_requests as requests
>>> r = requests.get('https://api.github.com/repos/dcoles/pycurl-requests')
>>> r.status_code
200
>>> r.headers['content-type']
'application/json; charset=utf-8'
>>> r.encoding
'utf-8'
>>> r.text
'{\n  "id": 236427187,\n...'
>>> data = r.json()
>>> data['name']
'pycurl-requests'
>>> data['html_url']
'https://github.com/dcoles/pycurl-requests'
>>> data['description']
'A Requests-compatible interface for pycURL'

The library can also be used to run existing Python scripts that import the requests module. By running the script through the pycurl_requests helper, any use of the requests module will be automatically redirected to pycurl_requests.

python3 -m pycurl_requests -- script.py arg arg...

request tool

A basic curl-like command-line utility is included:

usage: request.py [-h] [-d DATA] [-H HEADER] [--json JSON] [-L] [-o OUTPUT]
                  [-X REQUEST] [-v]
                  url

A basic `curl`-like command-line HTTP utility

positional arguments:
  url                   URL of resource to connect to

optional arguments:
  -h, --help            show this help message and exit
  -d DATA, --data DATA  Add POST data
  -H HEADER, --header HEADER
                        Add custom request header (format: `Header: Value`)
  --json JSON           Add JSON POST data
  -L, --location        Follow redirects
  -o OUTPUT, --output OUTPUT
                        Write to file instead of stdout
  -X REQUEST, --request REQUEST
                        Request command to use (e.g. HTTP method)
  -v, --verbose         Verbose logging

This can also be used with the Requests library if PYCURLREQUESTS_REQUESTS environment variable is set to a non-null value.

Documentation

This library aims to be API compatible with Requests, thus the Requests documentation should be mostly applicable.

cURL options

It is possible customize cURL's behaviour using the curl attribute on a Session object.

For example, to make a request without requesting the body:

import pycurl
import pycurl_requests as requests

with requests.Session() as session:
    session.curl.setopt(pycurl.NOBODY, 1)
    response = session.get('http://example.com')

See the pycurl.Curl object documentation for all possible curl attribute methods.

cURL exceptions

All pycurl.error exceptions are mapped to a requests.RequestException (or one of its subclasses).

For convenience, the original pycurl.error error message and cURL error code will be set on the exception object as the curl_message and curl_code attributes.

import pycurl_requests as requests

try:
    requests.get('http://connect_error')
except requests.RequestException as e:
    print('ERROR: {} (cURL error: {})'.format(e.curl_message, e.curl_code))

It is also possible to obtain the original pycurl.error using the __cause__ attribute.

Logging

Detailed log records from libcurl, including informational text and HTTP headers, can be shown by setting the curl logger (or sub-loggers) to DEBUG level:

import logging

logging.getLogger('curl').setLevel(logging.DEBUG)

Log records are split into dedicated sub-loggers for each type of record:

  • curl.text — Informational text
  • curl.header_in — Header data received from the peer
  • curl.header_out — Header data sent to the peer

Known limitations

Most of these features should be supported in the near future.

License

Licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].