fetch bing image urls based on keywords
Project description
Bing-Image-Urls
Fetch Bing image urls based on keywords
Installation
pip install bing-image-urls
Usage
from bing_image_urls import bing_image_urls
print(bing_iamge_urls("bear", limit=2))
# ['https://www.stgeorgeutah.com/wp-content/uploads/2017/01/blackbear.jpg',
# 'http://www.cariboutrailoutfitters.com/wp-content/uploads/2017/03/saskatchewan-black-bear-hunting.jpg']
The helper function get_image_size
may sometimes come handy if you need to know the size of the image. get_image_size
takes a filename or a filelike object as input and outputs the width and height of the image. Hence the raw bytes of an image from the net can be wrapped in io.BytesIO and fed to get_image_size
.
import io
import httpx
from logzero import logger
from bing_image_urls import get_image_size
url = "https://www.stgeorgeutah.com/wp-content/uploads/2017/01/blackbear.jpg"
try:
resp = httpx.get(url)
resp.raise_for_status()
except Exception as exc:
raise SystemExit(exc)
print(get_image_size(io.BytesIO(resp.content)))
# (1797, 2696)
Most of the code in get_image_size
is from imagesize_py. As soon as the PR about filelike object is merged to the main branch, the imagesize_py
package will be included as a depdendant package.
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
bing-image-urls-0.1.4.tar.gz
(6.0 kB
view hashes)
Built Distribution
Close
Hashes for bing_image_urls-0.1.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31c5ebd58f0c8d4cf5907c97a82d09a2eaa1291071617190a238557a69584f6b |
|
MD5 | 6ba9526a2f09420554c877f9cc440c6f |
|
BLAKE2b-256 | 61a008c0663826b5d2646c35a494ec75b6eed7332b912d83d41e5232efe0d4c4 |