Skip to main content

Bing-Image-Urls buildCode style: blackLicense: MITPyPI version

Fetch Bing image urls based on keywords

Installation

pip install bing-image-urls

Usage

from bing_image_urls import bing_image_urls

print(bing_image_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.

Metadata

Release files for bing-image-urls 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bing-image-urls 0.1.5
File Size Uploaded
bing-image-urls-0.1.5.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bing-image-urls 0.1.5
File Interpreter ABI Platform
bing_image_urls-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 13.1 kB

Release files / bing-image-urls-0.1.5.tar.gz

Download URL bing-image-urls-0.1.5.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
557d0c215283b0201705c107df37069fdc21e47ed80e6467a3e4681a4502f850
BLAKE2b-256 checksum
How to use checksums
8f7171c4d0186b9892e4105bf213e1faddb8f4d72d8179bde07a3d60cd02f3dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.1 CPython/3.8.10 Windows/10

Release files / bing_image_urls-0.1.5-py3-none-any.whl

Download URL bing_image_urls-0.1.5-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8870c7bdca0ccea6e111c4c87c48978f186549dc90e4ed9b10dc370a47cd9e7d
BLAKE2b-256 checksum
How to use checksums
56c1e428f889bb5d2ed534db17629743c6d409357250c2fecaf43ad4cd7bfdf3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.1 CPython/3.8.10 Windows/10

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page