Skip to main content

Pylunch

PyLunch was designed to scrape restaurants for it's daily menus and show them in multiple ways and formats.

Getting stated

PyLunch is a scraper, to use it, you have to install it. It is available at PyLunch

Install the released version

You can install the PyLunch using the pip:

$ pip install pylunch

Install the development version from github

  • Python 3.7 or later
  • (Optional) pipenv

Or you can add it as a development dependency using the pipenv

$ git clone https://github.com/pestanko/pylunch.git
$ cd pylunch
$ pipenv install # install the dependencies

Install Tesseract for OCR support

To support extracting text from images you need to install Tesseract. Then you need to download trained models for your language Tesseract data files wiki (English is supported by default).

Recommended are the best (most accurate) trained models. Save downloaded trained models to a dictionary with name tessdata. Expose environment variable TESSDATA_PREFIX with path to tessdata directory (i.e. TESSDATA_PREFIX=/tmp/tessdata).

You can specify different language when extracting data from the image for any restaurant with attribute language: <Lang code> in restaurants.yml file.

Dockerfile supported languages:

Language Lang code
English eng
Czech ces
Slovak slk

First Run

In order to run the tool correctly you need to configure it.

At first run the tool will create config folder in the home directory with restaurants database, by default it will be empty.

To use the zomato resolver you need to add the zomato_key to your configuration. In order to get the zomato key you need to go to the Zomato Api documentation

$ pylunch cfg-set zomato_key "<YOUR_KEY>"

To use the telegram integration, you need to set the telegram bot token property telegram_token. To get the telegram bot token please take a look here.

$ pylunch cfg-set telegram_token "<YOUR_KEY>"

To use the discord integration, you need to set the discord bot token property discord_token. For more information how to get them you go here.

$ pylunch cfg-set discord_token "<YOUR_KEY>"

Also if you have already created or exported database of the restaurants, you an import it using the command import: Example file is located in: resources/restaurants.yml available here.

$ pylunch import -O restaurants.yml

If you wish to load example from the repository you can use the curl and just pipe it to the import subcommand.

$ curl 'https://gitlab.com/pestanko/pylunch/raw/master/resources/restaurants.yml' | pylunch import -O 

In order to export the restaurants database file, you can use the export command.

$ pylunch export -f exported.yml

Run the cli tool

Hera is a help output with available commands.

# Show the help
$ pylunch --help

Usage: pylunch [OPTIONS] COMMAND [ARGS]...

  PyLunch CLI tool

Options:
  --version              Show the version and exit.
  -L, --log-level TEXT   Set log level (d|i|w|e) - default=w
  -C, --no-cache         Disable cache
  -c, --config-dir TEXT  Location to the configuration directory
  -F, --format TEXT      Set output format
  --help                 Show this message and exit.

Commands:
  add            Adds a new restaurant
  cache-clear    Clear a current cache for a day
  cache-content  Show the current cache for a day
  cfg-edit       Edit a configuration using the editor (Ex: VIM)
  cfg-set        Set a config value in the user configuration
  config         Shows the current configuration
  console        Start the interactive console (IPython)
  disable        Disables the restaurants
  edit           Edits restaurants DB file
  enable         Enables the restaurants
  export         Export restaurants
  import         Import restaurants
  info           Get info for the restaurant
  ls             List all available restaurants
  menu           Get menu for a restaurant
  rm             Removes the restaurant
  telegram-bot   Start the telegram bot

Runnig the server

As a server is used the Flask. To run the flask server please take a look to the documnetation.

In order to start the pylunch server take a look at the run_flask.ps1 or run_flask.sh scripts.

For access to the admin pages - in order to import restaurants or invalidate (refresh cache) you will need to set env variables:

PYLUNCH_SECRET=<JWT_SECRET>
PYLUNCH_USERS=PATH_TO_USERS_FILE

Admin user credentials:

Username: admin
Password: foobar1

Metadata

Release files for pylunch 0.2.9

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

Source distribution (sdist)

Source distribution for pylunch 0.2.9
File Size Uploaded Provenance
pylunch-0.2.9.tar.gz 54.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pylunch 0.2.9
File Interpreter ABI Platform
pylunch-0.2.9-py3-none-any.whl Python 3 none any Details

Total release size: 112.7 kB

Release files / pylunch-0.2.9.tar.gz

Download URL pylunch-0.2.9.tar.gz
Size 54.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c7b163d0cf3aa7a15d34ac2d8ae7ffe55eaae481885577d0d553a0bedcae4766
BLAKE2b-256 checksum
How to use checksums
53568ce5115bbdb74f15e3c42e6518b63018443b56b74e11768e97f2c4f5f6d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.7.6 Linux/5.5.5-200.fc31.x86_64

Release files / pylunch-0.2.9-py3-none-any.whl

Download URL pylunch-0.2.9-py3-none-any.whl
Size 58.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63eeaa1af8dc84d9987ab5228be6efe5d4318693b4d9be40b4974dd5f186b62c
BLAKE2b-256 checksum
How to use checksums
41458ed7dbea518d02ae50c1c986a68b14df9500b5b2b9cfebea61539c4e0227
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.7.6 Linux/5.5.5-200.fc31.x86_64

Security for pylunch 0.2.9

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.

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