-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetch_timetable.go
49 lines (38 loc) · 805 Bytes
/
fetch_timetable.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Copyright ©2016 The ji-web-display Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build ignore
package main
import (
"encoding/base64"
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
)
func main() {
id := flag.Int("id", 12779, "timetable ID")
host := flag.String("host", "indico.in2p3.fr", "Indico server")
flag.Parse()
url := fmt.Sprintf(
"https://%s/export/timetable/%d.json?pretty=yes",
*host, *id,
)
resp, err := http.Get(url)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
w := base64.NewEncoder(base64.StdEncoding, os.Stdout)
defer w.Close()
_, err = io.Copy(w, resp.Body)
if err != nil {
log.Fatal(err)
}
err = w.Close()
if err != nil {
log.Fatal(err)
}
}