Script for scraping unsplash. Only for educational purposes.
Install
from pypi
pip install unsplash-get
from github
pip install git+https://github.com/streanger/unsplash-get.git
Usage from command line
# as module
python -m unsplash_get <word>
python -m unsplash_get orange
# as entry point
unsplash <word>
unsplash orange
# as script
python unsplash_get.py <word>
python unsplash_get.py orange
Usage from Python (save images)
from pathlib import Path
from unsplash_get import search, save_img
# get list of urls
word = 'orange'
urls = search(word)
# create directory
directory = Path(word)
directory.mkdir(exist_ok=True)
# save images
for index, url in enumerate(urls, start=1):
path = str(directory / f'{word}_{index:03}.jpg')
status = save_img(url, path)
print(f"{index:03}.{url} -> {path} ({status})")
Usage from Python (load image to variable)
it requires additional libraries (PIL and/or numpy), which could be installed with
pip install Pillow numpy
example code
import io
import numpy as np
from PIL import Image
from unsplash_get import search, get_image
def load_img_to_pil(data):
img = Image.open(io.BytesIO(data))
return img
def load_image_to_numpy(data):
img = np.array(Image.open(io.BytesIO(data)))
return img
# get list of urls
word = 'orange'
urls = search(word)
url = urls[4]
# read image
data = get_image(url)
pil_img = load_img_to_pil(data)
numpy_img = load_image_to_numpy(data)
Screenshots
Metadata
Release files for unsplash-get 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| unsplash_get-0.1.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for unsplash_get-0.1.2-py2.py3-none-any.whl |
Release files / unsplash_get-0.1.2-py2.py3-none-any.whl
| Download URL | unsplash_get-0.1.2-py2.py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
cc9d7922a4f42fab623f8aa95e1e83b3b24a7cd3ef95a1d1f884bc349627205f
|
|
BLAKE2b-256 checksum How to use checksums |
ab8fa9819fc151f46451d72df74a9740a10bb85e77d5e4ccbe2daddd9218de40
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.3
|
Security for unsplash-get 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.