Skip to main content

Wrapper for urllib.request.urlopen

Project description

URL Request

wrapper for urllib.request.urlopen

Very limited drop-in replacement for requests when you cant import requests and need to use the built in urllib.request library

Supports (url,data,json,headers,timeout,auth)

Optional: Added (method) to be used in place to .post .get .etc takes: 'POST','GET','PUT','DELETE','HEAD','PATCH'

Added (callraise) default is true and will raise exceptions, false will disable exceptions.

Can be used via pip or just copy the class into your project

pip install urlrequest
from urlrequest import UrlRequest
response = UrlRequest('https://httpbin.org/ip')
print(response.text)
print(response.status_code)
print(response.headers)
print(response.json())

response = UrlRequest("https://httpbin.org/basic-auth/user/password",auth=('user','password'))
print(response.text)

response = UrlRequest("https://httpbin.org/post",method="POST",json={"hello":"world"})
print(response.text)

response = UrlRequest("https://httpbin.org/image/png")
with open("test.png","wb") as f:
    f.write(response.raw)
print(response.status_code)

# drop in for requests
from urlrequest import UrlRequest as requests
response = requests.get("https://httpbin.org/headers",headers={"hello":"world header test"})
print(response.text)

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

urlrequest-1.0.3.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

urlrequest-1.0.3-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file urlrequest-1.0.3.tar.gz.

File metadata

  • Download URL: urlrequest-1.0.3.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.15

File hashes

Hashes for urlrequest-1.0.3.tar.gz
Algorithm Hash digest
SHA256 21f823e8d9c6aacccf008efa09d94b9f42a28fc6d6c581f9116dc5c8722a1076
MD5 44dadf20ebe068cd87e22e0d5e2c682f
BLAKE2b-256 706477ddc6d9f7dcdb1bdf61fac062bcb79b6d0b343cbe4376d98ea379ad17cd

See more details on using hashes here.

File details

Details for the file urlrequest-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: urlrequest-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.15

File hashes

Hashes for urlrequest-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5f942913ce1f18dff3f41ea8ec8ac90cc6188105deaea00d12f0c587295bd7a2
MD5 8d1201ad0e3cf5671766642959fd93ed
BLAKE2b-256 4f81658bf03ff3566ff7add74ac7dbfefe8e6154ce94fcd533f4c9b235077622

See more details on using hashes here.

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