From 8d38c55b538c1b04635adbf54cacb6d3eb78f114 Mon Sep 17 00:00:00 2001 From: Dominika Date: Sun, 6 Sep 2020 23:49:58 +0200 Subject: [PATCH] fixups because I can't write;; Laura is very cute --- README.md | 4 ++-- platform.sh | 2 +- trains.sh | 7 ------- 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index e59b401..89d87c2 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,6 @@ This is a (very) work-in-progress project; Currently, there are two messy scripts: -`./platform.sh "Warszawa Centralna"` - gives links to PKP's static timetable page, usually with platforms listed +`./platform.sh "Warszawa Centralna" "Opole Główne"` - gives links to PKP's static timetable page, usually with platforms listed -`./trains.sh "Opole Główne"` - lists trains that will stop on station in the next few hours +`./trains.sh "Łódź Widzew"` - lists trains that will stop on station in the next few hours diff --git a/platform.sh b/platform.sh index 590181b..72609ea 100755 --- a/platform.sh +++ b/platform.sh @@ -16,5 +16,5 @@ detailsUrl=$(curl -s -c cookies.txt "https://rozklad-pkp.pl/pl/tp?queryPageDispl echo "https://rozklad-pkp.pl$detailsUrl" echo --- -curl -s -b cookies.txt -H "Cookie: NGINX1=ngnix11; NGINX=ngnix2;" "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' +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 diff --git a/trains.sh b/trains.sh index 150c3c6..4517b57 100755 --- a/trains.sh +++ b/trains.sh @@ -21,22 +21,15 @@ if [[ $(echo "$station" | grep -i "multiple") != '' ]]; then echo "$station" exit 0 fi - echo $station | grep -Poh "^[^:]+" url="http://infopasazer.intercity.pl/$(echo $station | grep -Poh "^[^:]+")" - data="$(curl $url | tr -d '\r' | tr -d '\n' | grep -Poh "")" IFS=$'\n' trains=$(echo $data | grep -Poh '.*?
.*?
') - - links=($(echo $data | grep -Poh "\?p\=train&id\=[0-9]+")) names=($(echo "$trains" | grep -Poh ">.*
.*" | sed -s 's// /g;s/<\/a>//g;s/^>//g')) for (( i=0; i<${#links[@]}; i++ )); do - #echo "${links[$i]} ---- ${names[$i]}" echo ${links[$i]}: ${names[$i]} done - -# Numer pociągu | Przewoźnik | Data | Relacja | Przyjazd planowo | Opóźnienie