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.4.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

urlrequest-1.0.4-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for urlrequest-1.0.4.tar.gz
Algorithm Hash digest
SHA256 879e0d502eb482371da91b3d5b17f9a462a92625e38318d100192639b35fdb9b
MD5 5c61fa15cfca5c7154da9587ae229e58
BLAKE2b-256 3a3568a207847d1bc9ab3500e256bc1cf8c6f28b5706f413a6c76820a36f3043

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for urlrequest-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 db90ed41b55ecfb9847e5312b48d9ada687c1d4cb82f5505e145ebed9a6ae70a
MD5 3ece5181b8f6b934ccf8065fb7be736c
BLAKE2b-256 d940bc8c5426247c6ed2abf5d3f7c7961106e0a9d0273c00a5dfec498887e5cf

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