21 lines
1.0 KiB
Bash
Executable File
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ń wszystkie' | sed -E 's/.*href="//g;s/" >.*//;s/\&/\&/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/\&/\&/g;s/\&\&/\&/g;s/trainlink/http\:\/\/rozklad-pkp.pl\/pl\/ti?&/g;s/&"$//g'
|
|
rm cookies.txt
|