Skip to content

ToshY/pexels-scraper

Repository files navigation

🖼️ Pexels scraper

Current bundle version Docker Hub Code style Code style Security check

A python command-line tool for scraping images from Pexels.com by topic search.

Info

Pexels.com is a platform which provides royalty-free photos and videos.

🧰 Requirements

  • A Pexels API key (can be requested after sign-up)
  • Docker

Note: By default, the API is rate-limited to 200 requests per hour and 20,000 requests per month. Read the Pexels Guidelines for more info.

🐋 Usage

  1. Pull the image.
docker pull t0shy/pexels-scraper:latest
  1. Run it.

Supply a JSON payload to search for a specific category. For available query parameters, see the API documentation.

docker run -it --rm \
  -u $(id -u):$(id -g) \
  -v $(pwd)/pexels/results:/output \
  t0shy/pexels-scraper:latest \
  -k "37c01053e18949935e52c0e9ddabc706166de7ca42c8357f0f4bf93e" \
  -p '{"query":"Nature"}'

Note: make sure to mount to the /output directory on the container.

  1. Check the results.
|-- ./pexels/results
  |-- 7203981.jpeg
  |-- ...
  |-- 7758348.jpeg

Note: a filename consists of id and original file extension.

🙋 Help

docker run -it --rm t0shy/pexels-scraper:latest -h
 _____              _         _____
|  __ \            | |       / ____|
| |__) |____  _____| |___   | (___   ___ _ __ __ _ _ __   ___ _ __
|  ___/ _ \ \/ / _ \ / __|   \___ \ / __| '__/ _` | '_ \ / _ \ '__|
| |  |  __/>  <  __/ \__ \   ____) | (__| | | (_| | |_) |  __/ |
|_|   \___/_/\_\___|_|___/  |_____/ \___|_|  \__,_| .__/ \___|_|
                                                  | |
                                                  |_|

usage: main.py [-h] -k API_KEY -p PAYLOAD [-d] [-v]

A python command-line tool for scraping images from Pexels.com by topic search.

options:
  -h, --help            show this help message and exit
  -k API_KEY, --key API_KEY
                        API key.
  -p PAYLOAD, --payload PAYLOAD
                        Payload in JSON format.
  -d, --debug           Debug loglevel; Fallback to WARNING.
  -v, --verbose         Info loglevel.

Repository: https://github.com/ToshY/pexels-scraper

🛠️ Contribute

Prerequisites

Pre-commit

Set up pre-commit.

pre-commit install

Checks

task contribute

Note: you can use task black:fix to resolve codestyle issues.

❕ License

This repository comes with a MIT license.