unsplash srape tool
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file unsplash_get-0.1.2-py2.py3-none-any.whl
.
File metadata
- Download URL: unsplash_get-0.1.2-py2.py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc9d7922a4f42fab623f8aa95e1e83b3b24a7cd3ef95a1d1f884bc349627205f |
|
MD5 | 2e9582d99a37e7d94fa442cf9381cd56 |
|
BLAKE2b-256 | ab8fa9819fc151f46451d72df74a9740a10bb85e77d5e4ccbe2daddd9218de40 |