Skip to content

Commit

Permalink
change calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
xjl0 committed Dec 26, 2023
1 parent fa7552b commit e493a03
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions pkg/calendar/calendar.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"github.com/PuerkitoBio/goquery"
"net/http"
"strings"
"time"
)

Expand All @@ -18,7 +17,7 @@ func CalendarReq() (string, error) {
Timeout: 15 * time.Second,
}

req, err := http.NewRequestWithContext(ctxHttp, "GET", "https://kakoysegodnyaprazdnik.ru/", nil)
req, err := http.NewRequestWithContext(ctxHttp, "GET", "https://kakoysegodnyaprazdnik.com/", nil)
if err != nil {
return "", err
}
Expand All @@ -33,16 +32,12 @@ func CalendarReq() (string, error) {
return "", err
}
var result string
count := 0
doc.Find(".listing .listing_wr .main").Each(func(i int, s *goquery.Selection) {
if count < 20 {
text := s.Find("span").First().Text()
text = strings.Replace(text, "США", ":flag_um:", 1)
text = strings.Replace(text, "Япония", ":flag_jp:", 1)
result += ":small_blue_diamond: " + text + "\n"
}
count++
div := doc.Find("div.boxed-text").First()
div.Find("li").Each(func(i int, s *goquery.Selection) {
text := s.Text()
result += ":small_orange_diamond: " + text + "\n"
})
result = "**Праздники сегодня kakoysegodnyaprazdnik.ru**\n" + result

result = "**Праздники сегодня kakoysegodnyaprazdnik.com**\n" + result
return result, nil
}

0 comments on commit e493a03

Please sign in to comment.