Package: renfe-cli
Renfe Timetables CLIGet faster Renfe trains timetables in your terminal, with Python3.7+ support.
No longer need to open the browser! Just keep using your terminal 😀renfe-cliis written inRust(since v4.0.0) and published topypi.orgas a Python package (CLI and library).See thechangelog.NOTEsince I am more often using Rodalies trains I have createdrodalies-cli. I hope you like it too!InstallationInstall Python CLI packagerenfe-clipipinstallrenfe-cli--upgradeUsage (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:Writes down and selects origin stationWrites down and selects destination stationWrites down and selects the day to search forWrites down and selects the month to search forWrites down and selects the year to search forClicks on search buttonParses the HTML data, optionally sorts the connections and prints the timetable$renfe-cli-h
Usage:renfe-cli[options]Options:-fORIGINSetFromoriginstation-tDESTINATIONSetTodestinationstation-d,--dayDAYSetDaytosearchtimetablefor(default:today)-m,--monthMONTHSetMonthtosearchtimetablefor(default:today's month)-y, --year YEAR     Set Year to search timetable for (default: today'syear)-w,--waitSECONDSSetWaittimeinsecondsforRenfesearchresultpage(default:2)-s,--sortOptiontosortthetimetablebyDuration-h,--helpPrintthishelpmenuGetting the timetableLet's show an example of minimal inputs (origin and destination stations) with specific date:$renfe-cli-fBarc-tMad-d27LoadingstationsfromRenfeweb
Providedinput'Barc'stationmatcheswith'Barcelona (ALL) '...continue
Providedinput'Mad'stationmatcheswith'Madrid (ALL) '...continue
Todayis:2023-11-26
Searchingtimetablefordate:2023-11-27
loadingheadlesschromebrowser
navigatingtorenfetimetablesearchpage
waitingforsearchpage
addingoriginstation
addingdestinationstation
addingday
addingmonth
addingyear
searchingtimetable
gottimetablepage
loadingtimetable=========================TIMETABLE=========================Train|Departure|Arrival|Duration
-----------------------------------------------------------
AVE|05.50|09.10|3h.20min.
-----------------------------------------------------------
AVE|06.20|08.50|2h.30min.
-----------------------------------------------------------
AVLO|06.35|09.20|2h.45min.
-----------------------------------------------------------
AVE|07.00|09.30|2h.30min.
-----------------------------------------------------------
AVE|07.40|10.10|2h.30min.
-----------------------------------------------------------
LD-AVE|07.45|15.35|7h.50min.
-----------------------------------------------------------
AVE|08.00|11.12|3h.12min.
-----------------------------------------------------------
AVE|08.25|10.55|2h.30min.
-----------------------------------------------------------
REG.EXP.|08.43|18.09|9h.26min.
-----------------------------------------------------------
AVE|09.00|11.45|2h.45min.
-----------------------------------------------------------
AVLO|10.00|13.17|3h.17min.
-----------------------------------------------------------
AVE|11.00|13.45|2h.45min.
-----------------------------------------------------------
AVE|12.00|15.12|3h.12min.
-----------------------------------------------------------
AVEINT|12.50|15.45|2h.55min.
-----------------------------------------------------------
AVE|13.25|15.54|2h.29min.
-----------------------------------------------------------
AVE|14.00|17.12|3h.12min.
-----------------------------------------------------------
AVLO|15.00|17.45|2h.45min.
-----------------------------------------------------------
AVE|15.25|17.55|2h.30min.
-----------------------------------------------------------
AVE|16.00|19.12|3h.12min.
-----------------------------------------------------------
AVE|16.25|18.55|2h.30min.
-----------------------------------------------------------
AVE|17.00|19.45|2h.45min.
-----------------------------------------------------------
AVE|17.25|19.55|2h.30min.
-----------------------------------------------------------
AVE|18.00|21.12|3h.12min.
-----------------------------------------------------------
AVE|18.25|20.55|2h.30min.
-----------------------------------------------------------
AVE|18.40|21.45|3h.5min.
-----------------------------------------------------------
AVE|19.25|21.55|2h.30min.
-----------------------------------------------------------
AVE|20.00|23.12|3h.12min.
-----------------------------------------------------------
AVLO|21.00|23.45|2h.45min.
-----------------------------------------------------------
AVE|21.25|23.55|2h.30min.===========================================================Usage (Library)renfe-clican be imported as a python package into your project, offering utilities when willing to deal with the Renfe search web site.$python
Python3.8.18(default,Aug252023,13:20:30)[GCC11.4.0]onlinux
Type"help","copyright","credits"or"license"formoreinformation.
>>>importrenfe_cli
>>>renfe=renfe_cli.
renfe_cli.Renfe(renfe_cli.main(renfe_cli.print_timetable(renfe_cli.renfe_clirenfe_cli.search_timetable(>>>renfe=renfe_cli.Renfe()LoadingstationsfromRenfeweb
>>>renfe.
renfe.filter_station(renfe.stations_match(>>>renfe.stations_match("Bar")['Barcelona (ALL) ','Padrón-Barbanza']Contribute or Report with IssuesIf Renfe's website is changed or you find any issue to be fixed or nice enhancements to have, please:create an issue.DevelopmentThis project makes use of Rust bindings for the Python interpreter thanks topyo3. It is already available as a dependency.To develop, build and publish, this project makes use ofmaturinproject. Seeusage.Example of first time working with this repository:$gitclonehttps://github.com/gerardcl/renfe-cli.git&&cdrenfe-cli
$python-mvenvvenv
$.venv/bin/activate
$pipinstall-Upip
$pipinstall-Umaturin
$maturindevelop
🔗Foundpyo3bindingswithabi3supportforPython≥3.7
🐍Notusingaspecificpythoninterpreter
📡Usingbuildoptionsfeaturesfrompyproject.tomlCompilingrenfe-cliv4.1.0(/path/to/renfe-cli)Finisheddev[unoptimized+debuginfo]target(s)in7.07s
📦Builtwheelforabi3Python≥3.7to/tmp/.tmpDsjowL/renfe_cli-4.1.0-cp37-abi3-linux_x86_64.whl
🛠Installedrenfe-cli-4.1.0Maturin takes care of compiling the rust code, generating the bindings for python and installing the package for local use (as library or binary/CLI).