Last active
March 6, 2018 13:23
-
-
Save ipcjk/882c39090840715531150e19cb6868ba to your computer and use it in GitHub Desktop.
Check you personalausweis or travel pass pickup availability of KVR Muenchen, e.g. from a cronjob
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"log" | |
"net/http" | |
"net/url" | |
"os" | |
"strings" | |
) | |
func main() { | |
if len(os.Args) <= 1 { | |
log.Fatal("Zu wenig Argumente") | |
} | |
data := url.Values{} | |
data.Add("ifNummer", os.Args[1]) | |
data.Add("pbAbfragen", "Abfragen") | |
req, err := http.NewRequest("POST", "https://www17.muenchen.de/Passverfolgung/", strings.NewReader(data.Encode())) | |
if err != nil { | |
log.Fatal(err) | |
} | |
req.Header.Add("Content-type", "application/x-www-form-urlencoded") | |
client := http.Client{} | |
resp, err := client.Do(req) | |
if err != nil { | |
log.Fatal(err) | |
} | |
defer resp.Body.Close() | |
scanner := bufio.NewScanner(resp.Body) | |
for scanner.Scan() { | |
if strings.Contains(scanner.Text(), "Ein Dokument mit dieser Nummer ist nicht vorhanden") { | |
fmt.Println(os.Args[1], " - diese Passnummer ist falsch!") | |
} else if strings.Contains(scanner.Text(), " noch nicht zur Abholung bereit.") { | |
fmt.Println(os.Args[1], "liegt noch nicht zur Abholung bereit.") | |
} else if strings.Contains(scanner.Text(), `liegt zur<B STYLE="color: green"> Abholung bereit.</B></TD>`) { | |
fmt.Println(os.Args[1], "liegt zur Abholung bereit, yes!") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment