https://github.com/cs01/you-might-not-need-requests
alternative ways to make http requests in Python without the requests package
https://github.com/cs01/you-might-not-need-requests
Last synced: 4 months ago
JSON representation
alternative ways to make http requests in Python without the requests package
- Host: GitHub
- URL: https://github.com/cs01/you-might-not-need-requests
- Owner: cs01
- Created: 2019-05-06T16:12:12.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-06T16:16:12.000Z (about 7 years ago)
- Last Synced: 2025-03-04T09:43:06.321Z (over 1 year ago)
- Homepage:
- Size: 0 Bytes
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
*This is a work in progress*
The Python `requests` package creates a convenient API to make http requests, but comes at the price of adding a 3rd party dependency to your project.
You might be able to get away with using Python's standard library (and keeping your sanity) if you're doing something simple.
Feel free to copy any of these code snippets to your codebase, no attribution required.
### http GET request
requests
```python
import requests
requests.get(url)
```
without requests
```python
import urllib.parse
import urllib.request
def http_get(url):
res = urllib.request.urlopen(url)
charset = res.headers.get_content_charset() or "utf-8"
return res.read().decode(charset)
```