unsplash_get
======================
Script for scraping unsplash. Only for educational purposes.
Install
**************************
from pypi
.. code-block:: bash
pip install unsplash-get
from github
.. code-block:: bash
pip install git+https://github.com/streanger/unsplash-get.git
Usage from command line
**************************
.. code-block:: bash
# 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)
*********************************************
.. code-block:: python
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
.. code-block:: bash
pip install Pillow numpy
example code
.. code-block:: python
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
**************************
.. image:: https://raw.githubusercontent.com/streanger/unsplash-get/master/images/unsplash1.png
Raw data
{
"_id": null,
"home_page": "https://github.com/streanger/unsplash_get",
"name": "unsplash-get",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "unsplash scrape stock images",
"author": "streanger",
"author_email": "divisionexe@gmail.com",
"download_url": "",
"platform": null,
"description": "unsplash_get\r\n======================\r\nScript for scraping unsplash. Only for educational purposes.\r\n\r\nInstall\r\n**************************\r\n\r\nfrom pypi\r\n\r\n.. code-block:: bash\r\n\r\n pip install unsplash-get\r\n\r\nfrom github\r\n\r\n.. code-block:: bash\r\n\r\n pip install git+https://github.com/streanger/unsplash-get.git\r\n\r\nUsage from command line\r\n**************************\r\n\r\n.. code-block:: bash\r\n\r\n # as module\r\n python -m unsplash_get <word>\r\n python -m unsplash_get orange\r\n\r\n # as entry point\r\n unsplash <word>\r\n unsplash orange\r\n\r\n # as script\r\n python unsplash_get.py <word>\r\n python unsplash_get.py orange\r\n\r\nUsage from Python (save images)\r\n*********************************************\r\n\r\n.. code-block:: python\r\n\r\n from pathlib import Path\r\n from unsplash_get import search, save_img\r\n\r\n # get list of urls\r\n word = 'orange'\r\n urls = search(word)\r\n\r\n # create directory\r\n directory = Path(word)\r\n directory.mkdir(exist_ok=True)\r\n\r\n # save images\r\n for index, url in enumerate(urls, start=1):\r\n path = str(directory / f'{word}_{index:03}.jpg')\r\n status = save_img(url, path)\r\n print(f\"{index:03}.{url} -> {path} ({status})\")\r\n\r\nUsage from Python (load image to variable)\r\n*********************************************\r\n\r\nit requires additional libraries (**PIL** and/or **numpy**), which could be installed with\r\n\r\n.. code-block:: bash\r\n\r\n pip install Pillow numpy\r\n\r\nexample code\r\n\r\n.. code-block:: python\r\n\r\n import io\r\n import numpy as np\r\n from PIL import Image\r\n from unsplash_get import search, get_image\r\n\r\n def load_img_to_pil(data):\r\n img = Image.open(io.BytesIO(data))\r\n return img\r\n\r\n def load_image_to_numpy(data):\r\n img = np.array(Image.open(io.BytesIO(data)))\r\n return img\r\n\r\n # get list of urls\r\n word = 'orange'\r\n urls = search(word)\r\n url = urls[4]\r\n\r\n # read image\r\n data = get_image(url)\r\n pil_img = load_img_to_pil(data)\r\n numpy_img = load_image_to_numpy(data)\r\n\r\nScreenshots\r\n**************************\r\n\r\n.. image:: https://raw.githubusercontent.com/streanger/unsplash-get/master/images/unsplash1.png\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "unsplash srape tool",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/streanger/unsplash_get"
},
"split_keywords": [
"unsplash",
"scrape",
"stock",
"images"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ab8fa9819fc151f46451d72df74a9740a10bb85e77d5e4ccbe2daddd9218de40",
"md5": "2e9582d99a37e7d94fa442cf9381cd56",
"sha256": "cc9d7922a4f42fab623f8aa95e1e83b3b24a7cd3ef95a1d1f884bc349627205f"
},
"downloads": -1,
"filename": "unsplash_get-0.1.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "2e9582d99a37e7d94fa442cf9381cd56",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 5096,
"upload_time": "2023-12-07T23:47:53",
"upload_time_iso_8601": "2023-12-07T23:47:53.728707Z",
"url": "https://files.pythonhosted.org/packages/ab/8f/a9819fc151f46451d72df74a9740a10bb85e77d5e4ccbe2daddd9218de40/unsplash_get-0.1.2-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-07 23:47:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "streanger",
"github_project": "unsplash_get",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "unsplash-get"
}