From 17e05636a5a3e51d8ed3017c0434b89649835f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D0=BC=D0=B8=D1=80=20=D0=A4?= =?UTF-8?q?=D0=B5=D0=B4=D0=BE=D1=80=D0=BE=D0=B2?= Date: Mon, 25 Apr 2022 13:16:30 +0700 Subject: [PATCH] fix schedule --- messages/messages.go | 2 +- parser/examples/main.go | 12 ++++++++++++ parser/parser.go | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 parser/examples/main.go diff --git a/messages/messages.go b/messages/messages.go index e983b1c..d1daf59 100644 --- a/messages/messages.go +++ b/messages/messages.go @@ -27,7 +27,7 @@ func ThanksMessage() string { } func HelpMessage() string { - return "Вот чем я могу вам помочь (v1.0.2), отправь:\n\n" + + return "Вот чем я могу вам помочь (v1.0.3), отправь:\n\n" + "- /ping отобью pong\n" + "- /today_lessons покажу расписание на сегодня\n" + "- /tomorrow_lessons покажу расписание на завтра\n" + diff --git a/parser/examples/main.go b/parser/examples/main.go new file mode 100644 index 0000000..acf2c65 --- /dev/null +++ b/parser/examples/main.go @@ -0,0 +1,12 @@ +package main + +import ( + "fmt" + "student_bot/date" + "student_bot/parser" +) + +func main() { + lessons := parser.ParseByDay(date.Today()) + fmt.Println(lessons) +} diff --git a/parser/parser.go b/parser/parser.go index 6145f63..3699708 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -46,7 +46,7 @@ func parse() []Lesson { k := 0 var lessons []Lesson var l Lesson - doc.Find(".schedule tr>td, .schedule tr>td[width=\"100%\"]").Each(func(i int, s *goquery.Selection) { + doc.Find(".schedule_table tr td").Each(func(i int, s *goquery.Selection) { text := strings.TrimSpace(s.Text()) if strings.Contains(text, "Понедельник") || strings.Contains(text, "Вторник") ||