Skip to main content

Get faster Renfe Spanish Trains timetables in your terminal.

Project description

CICD

Renfe Timetables CLI

Get faster Renfe trains timetables in your terminal, with Python3.7+ support. No longer need to open the browser! Just keep using your terminal 😀

renfe-cli is written in Rust (since v4.0.0) and published to pypi.org as a Python package (CLI and library).

See the changelog.

NOTE since I am more often using Rodalies trains I have created rodalies-cli. I hope you like it too!

Installation

Install Python CLI package renfe-cli

pip install renfe-cli --upgrade

Usage (CLI)

This CLI behaves as a person/bot going through the official renfe.com search site, using headless chrome browser. If the headless chrome browser is not found it will be downloaded.

The navigation through the site happens in the following steps:

  1. Writes down and selects origin station
  2. Writes down and selects destination station
  3. Writes down and selects the day to search for
  4. Writes down and selects the month to search for
  5. Writes down and selects the year to search for
  6. Clicks on search button
  7. Parses the HTML data and prints the timetable
$ renfe-cli -h
Usage: renfe-cli [options]

Options:
    -f ORIGIN           Set From origin station
    -t DESTINATION      Set To destination station
    -d, --day DAY       Set Day to search timetable for (default: today)
    -m, --month MONTH   Set Month to search timetable for (default: today's month)
    -y, --year YEAR     Set Year to search timetable for (default: today's year)
    -w, --wait SECONDS  Set Wait time in seconds for Renfe search result page (default: 2)
    -h, --help          Print this help menu

Getting the timetable

Let's show an example of minimal inputs (origin and destination stations) with specific date:

$ renfe-cli -f Barc -t Mad -d 27
Loading stations from Renfe web
Provided input 'Barc' station matches with 'Barcelona (ALL) '...continue
Provided input 'Mad' station matches with 'Madrid (ALL) '...continue
Today is: 2023-11-26
Searching timetable for date: 2023-11-27
loading headless chrome browser
navigating to renfe timetable search page
waiting for search page
adding origin station
adding destination station
adding day
adding month
adding year
searching timetable
got timetable page
loading timetable
=========================TIMETABLE=========================
Train        |   Departure  |   Arrival    | Duration
-----------------------------------------------------------
AVE          |    05.50     |    09.10     | 3 h. 20 min.
-----------------------------------------------------------
AVE          |    06.20     |    08.50     | 2 h. 30 min.
-----------------------------------------------------------
AVLO         |    06.35     |    09.20     | 2 h. 45 min.
-----------------------------------------------------------
AVE          |    07.00     |    09.30     | 2 h. 30 min.
-----------------------------------------------------------
AVE          |    07.40     |    10.10     | 2 h. 30 min.
-----------------------------------------------------------
LD-AVE       |    07.45     |    15.35     | 7 h. 50 min.
-----------------------------------------------------------
AVE          |    08.00     |    11.12     | 3 h. 12 min.
-----------------------------------------------------------
AVE          |    08.25     |    10.55     | 2 h. 30 min.
-----------------------------------------------------------
REG.EXP.     |    08.43     |    18.09     | 9 h. 26 min.
-----------------------------------------------------------
AVE          |    09.00     |    11.45     | 2 h. 45 min.
-----------------------------------------------------------
AVLO         |    10.00     |    13.17     | 3 h. 17 min.
-----------------------------------------------------------
AVE          |    11.00     |    13.45     | 2 h. 45 min.
-----------------------------------------------------------
AVE          |    12.00     |    15.12     | 3 h. 12 min.
-----------------------------------------------------------
AVE INT      |    12.50     |    15.45     | 2 h. 55 min.
-----------------------------------------------------------
AVE          |    13.25     |    15.54     | 2 h. 29 min.
-----------------------------------------------------------
AVE          |    14.00     |    17.12     | 3 h. 12 min.
-----------------------------------------------------------
AVLO         |    15.00     |    17.45     | 2 h. 45 min.
-----------------------------------------------------------
AVE          |    15.25     |    17.55     | 2 h. 30 min.
-----------------------------------------------------------
AVE          |    16.00     |    19.12     | 3 h. 12 min.
-----------------------------------------------------------
AVE          |    16.25     |    18.55     | 2 h. 30 min.
-----------------------------------------------------------
AVE          |    17.00     |    19.45     | 2 h. 45 min.
-----------------------------------------------------------
AVE          |    17.25     |    19.55     | 2 h. 30 min.
-----------------------------------------------------------
AVE          |    18.00     |    21.12     | 3 h. 12 min.
-----------------------------------------------------------
AVE          |    18.25     |    20.55     | 2 h. 30 min.
-----------------------------------------------------------
AVE          |    18.40     |    21.45     | 3 h. 5 min.
-----------------------------------------------------------
AVE          |    19.25     |    21.55     | 2 h. 30 min.
-----------------------------------------------------------
AVE          |    20.00     |    23.12     | 3 h. 12 min.
-----------------------------------------------------------
AVLO         |    21.00     |    23.45     | 2 h. 45 min.
-----------------------------------------------------------
AVE          |    21.25     |    23.55     | 2 h. 30 min.
===========================================================

Usage (Library)

renfe-cli can be imported as a python package into your project, offering utilities when willing to deal with the Renfe search web site.

$ python
Python 3.8.18 (default, Aug 25 2023, 13:20:30)
[GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import renfe_cli
>>> renfe = renfe_cli.
renfe_cli.Renfe(             renfe_cli.main(              renfe_cli.print_timetable(   renfe_cli.renfe_cli          renfe_cli.search_timetable(
>>> renfe = renfe_cli.Renfe()
Loading stations from Renfe web
>>> renfe.
renfe.filter_station(  renfe.stations_match(
>>> renfe.stations_match("Bar")
['Barcelona (ALL) ', 'Padrón-Barbanza']

Contribute or Report with Issues

If Renfe's website is changed or you find any issue to be fixed or nice enhancements to have, please: create an issue.

Development

This project makes use of Rust bindings for the Python interpreter thanks to pyo3. It is already available as a dependency.

To develop, build and publish, this project makes use of maturin project. See usage.

Example of first time working with this repository:

$ git clone https://github.com/gerardcl/renfe-cli.git && cd renfe-cli
$ python -m venv venv
$ . venv/bin/activate
$ pip install -U pip
$ pip install -U maturin
$ maturing develop
🔗 Found pyo3 bindings with abi3 support for Python  3.7
🐍 Not using a specific python interpreter
📡 Using build options features from pyproject.toml
   Compiling renfe-cli v4.1.0 (/path/to/renfe-cli)
    Finished dev [unoptimized + debuginfo] target(s) in 7.07s
📦 Built wheel for abi3 Python  3.7 to /tmp/.tmpDsjowL/renfe_cli-4.1.0-cp37-abi3-linux_x86_64.whl
🛠 Installed renfe-cli-4.1.0

Maturin takes care of compiling the rust code, generating the bindings for python and installing the package for local use (as library or binary/CLI).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

renfe_cli-4.2.0.tar.gz (25.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

renfe_cli-4.2.0-cp37-abi3-win_amd64.whl (3.9 MB view details)

Uploaded CPython 3.7+Windows x86-64

renfe_cli-4.2.0-cp37-abi3-win32.whl (3.4 MB view details)

Uploaded CPython 3.7+Windows x86

renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ x86-64

renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (6.7 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ s390x

renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (6.6 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ppc64le

renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (6.4 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ i686

renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (5.8 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.17+ ARMv7l

renfe_cli-4.2.0-cp37-abi3-macosx_11_0_arm64.whl (4.0 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

renfe_cli-4.2.0-cp37-abi3-macosx_10_7_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.7+macOS 10.7+ x86-64

File details

Details for the file renfe_cli-4.2.0.tar.gz.

File metadata

  • Download URL: renfe_cli-4.2.0.tar.gz
  • Upload date:
  • Size: 25.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.3.2

File hashes

Hashes for renfe_cli-4.2.0.tar.gz
Algorithm Hash digest
SHA256 8473a8db849eb74d6d4f0bfb94adcb6282d494cde88dd9e0ee14631a08cf17a2
MD5 3f70a20e0e933165dea88338fa40f55f
BLAKE2b-256 eabe250f5f6b20860f6de01d87e8c00d6742117a65a376374e5ec94ab336c5b1

See more details on using hashes here.

File details

Details for the file renfe_cli-4.2.0-cp37-abi3-win_amd64.whl.

File metadata

  • Download URL: renfe_cli-4.2.0-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.9 MB
  • Tags: CPython 3.7+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.3.2

File hashes

Hashes for renfe_cli-4.2.0-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 ff9e8eb3f1645dbd088fd07b388c63ff4c323dac676b33b138e716e48126b002
MD5 01bef3f5c8ffa49ff084ae569e38b45d
BLAKE2b-256 c42e6a1ac0b06aa668a5bd44b43f6f0b82d6a11720d5cab13966ba1343b25600

See more details on using hashes here.

File details

Details for the file renfe_cli-4.2.0-cp37-abi3-win32.whl.

File metadata

  • Download URL: renfe_cli-4.2.0-cp37-abi3-win32.whl
  • Upload date:
  • Size: 3.4 MB
  • Tags: CPython 3.7+, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.3.2

File hashes

Hashes for renfe_cli-4.2.0-cp37-abi3-win32.whl
Algorithm Hash digest
SHA256 08ed1cf72516047a6f61b107e2b30394f111301004866fba48b75a2d5ab7af69
MD5 45edacdb044b61470ac159e355742bfd
BLAKE2b-256 a51b92a1bd921afc4cfabc76bfca2f7577b5d9fa73da9186edb79e361bdb8535

See more details on using hashes here.

File details

Details for the file renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9501c1c87712f8e141f5ac83e8639b631f7d2bc17762cbbeaf7908cad489f5f7
MD5 67cc9310524fd9d002b4994bda7c2a8a
BLAKE2b-256 95bdb8b5a995fc7dd7d9b363fe65094dea17ae7ab2f71dab767d5ace3ad2b928

See more details on using hashes here.

File details

Details for the file renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 0ccb09dd61714ba189094cf0054bd980ade0ce280bf13c66d28a5a49ba50df65
MD5 2dd7feac1d2ec59ccdd4af148becf17d
BLAKE2b-256 68e64bf30dae8dfee78f2305be4264364436233aab4e5769f786b17b21dbe187

See more details on using hashes here.

File details

Details for the file renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 c4756ea6fa1195644dafff8faf15606ea4089c0746defd1f9c4deb3440ea997c
MD5 87554cefd88941cd8886a75e05284188
BLAKE2b-256 14f3c3b1a24d8c9d13b8dcb3fb5cdd3f8ddbb9ebd813d448e2110e5424ec3a32

See more details on using hashes here.

File details

Details for the file renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 2257b021158143cd04698a8ffe5e0a68388f94945e3a851465170a5c60c4727a
MD5 f5d77ba5d0bf1beb6573a3c7030d894d
BLAKE2b-256 f93bdf5e25ef033553a034fae5b17e33c52492016e433cf67756ee8138d5cbd4

See more details on using hashes here.

File details

Details for the file renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for renfe_cli-4.2.0-cp37-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 cb3775fa00953c58ce34d72d9eda58d28fb9330e0e12881dc9207b6c45a15b3c
MD5 d781f7316bacae7f4edcfdea67c7fbd4
BLAKE2b-256 435753468a588e07e8283d5f391473835616557a096024f4c35b4864c91b60c3

See more details on using hashes here.

File details

Details for the file renfe_cli-4.2.0-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for renfe_cli-4.2.0-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 32d1e979df34e7ad01dbccfa9186a18eca6ced043fdbc0a0872fbf7358f8d926
MD5 1162f30c621d53ce22dd708d907294b5
BLAKE2b-256 7b03b85548f55ed9b6940f99f91ab50a4a9fd2ed0193e2795e4f31bb8491b392

See more details on using hashes here.

File details

Details for the file renfe_cli-4.2.0-cp37-abi3-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for renfe_cli-4.2.0-cp37-abi3-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 f8724629e0e09842785b716117af9223cfe8c3b143519ea3d3f9a481d99113ed
MD5 243ae536e347595da746a32b50481942
BLAKE2b-256 049dd25401f5f8bc98be54888cac69c4d2753e6ce586410809e5518e23160b20

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page