pkp-tools/platform.sh

21 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
stationStart=$(jq -nr --arg v "$1" '$v|@uri')
stationEnd=$(jq -nr --arg v "$2" '$v|@uri')
stationStartId=$(curl -s "https://rozklad-pkp.pl/station/search?term=$stationStart&short=false" | jq '.[0].value|tonumber')
stationEndId=$(curl -s "https://rozklad-pkp.pl/station/search?term=$stationEnd&short=false" | jq '.[0].value|tonumber')
time=$(date "+%H:%M")
date=$(date "+%d.%m.%y")
detailsUrl=$(curl -s -c cookies.txt "https://rozklad-pkp.pl/pl/tp?queryPageDisplayed=yes&REQ0JourneyStopsS0A=1&REQ0JourneyStopsS0G=$stationStartId&REQ0JourneyStopsZ0A=1&REQ0JourneyStopsZ0G=$stationEndId&date=$date&time=$time&REQ0JourneyProduct_opt_section_0_list=1:100000&start=start&came_from_form=1" | grep -Poh '<a class="do-print".*?Rozwi&#324; wszystkie' | sed -E 's/.*href="//g;s/" >.*//;s/\&amp;/\&/g;s/\&\&/\&/g;')
echo "https://rozklad-pkp.pl$detailsUrl"
echo ---
curl -s -b cookies.txt "https://rozklad-pkp.pl$detailsUrl" | grep -Poh 'trainlink.*?"' | sed -s 's/\&amp;/\&/g;s/\&\&/\&/g;s/trainlink/http\:\/\/rozklad-pkp.pl\/pl\/ti?&/g;s/&"$//g'
rm cookies.txt