반응형
The fastest library for downloading image
특징
- Thread safety.
- Connection pooling.
- Client-side SSL/TLS verification.
- File uploads with multipart encoding.
- Helpers for retrying requests and dealing with HTTP redirects.
- Support for gzip, deflate, and brotli encoding.
- Proxy support for HTTP and SOCKS.
- 100% test coverage.
설치
python -m pip install urllib3
예제1
import urllib3
http = urllib3.PoolManager()
resp = http.request("GET", "http://httpbin.org/robots.txt")
resp.status
# 200
resp.data
# b"User-agent: *\nDisallow: /deny\n"
예제2
from PIL import Image
from io import BytesIO
import urllib3
http = urllib3.PoolManager()
image_url = 'http://...image url...'
r = http.request('GET', image_url, preload_content=False)
image = Image.open(BytesIO(r.read()))
r.release_conn()
728x90
반응형
'Python' 카테고리의 다른 글
[Python] 여러 폴더의 파일을 날짜별로 분류해보기 (2) | 2022.01.17 |
---|---|
[Tensorflow] TypeError: evaluate() got an unexpected keyword argument 'return_dict' 문제 (0) | 2022.01.07 |
[Python] pip 전역으로 설치하기. interpreter 골라서 pip 설치 (0) | 2021.07.15 |
[Python] flip : 이미지 반전 옵션 (0) | 2021.07.12 |
[Python] Mysql Connection Pool 사용하기 (0) | 2021.06.18 |
댓글