fix расписание

This commit is contained in:
Владимир Фёдоров 2022-09-04 15:45:52 +07:00
parent 17e05636a5
commit a707f0a6ca
1 changed files with 12 additions and 2 deletions

View File

@ -1,13 +1,18 @@
package parser package parser
import ( import (
"github.com/PuerkitoBio/goquery" "fmt"
"io" "io"
"log" "log"
"net/http" "net/http"
"strings" "strings"
"time"
"github.com/PuerkitoBio/goquery"
) )
const scheduleURLTemplate = "https://www.asu.ru/timetable/students/12/2129440415/?date=%s-%s"
type Lesson struct { type Lesson struct {
Day int Day int
Number string Number string
@ -22,7 +27,12 @@ func ParseByDay(day int) []Lesson {
} }
func parse() []Lesson { func parse() []Lesson {
url := "https://www.asu.ru/timetable/students/12/2129440415/" location, err := time.LoadLocation("Asia/Novosibirsk")
if err != nil {
panic(err)
}
now := time.Now().In(location)
url := fmt.Sprintf(scheduleURLTemplate, now.Format("20060102"), now.Add(24*time.Hour).Format("20060102"))
// Get html // Get html
res, err := http.Get(url) res, err := http.Get(url)