-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (36 loc) · 843 Bytes
/
main.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
package main
import (
"github.com/PuerkitoBio/goquery"
"github.com/nlopes/slack"
)
// settings of slack
const (
WEBHOOKURL = ""
)
// GetPage function
func GetPage(url string) {
doc, _ := goquery.NewDocument(url)
doc.Find("#topics_list4 li").Each(func(_ int, s *goquery.Selection) {
imageURL, _ := s.Find("img").Attr("src")
url, _ := s.Find(".pic a").Attr("href")
shopName := s.Find(".shop-nm .name").Text()
text := url + "\n" + shopName
PostSlack(text, imageURL)
})
}
// PostSlack function
func PostSlack(text, imageURL string) {
payload := &slack.WebhookMessage{
Attachments: []slack.Attachment{
{
Text: text,
ImageURL: imageURL,
},
},
}
slack.PostWebhook(WEBHOOKURL, payload)
}
func main() {
url := "https://pets-kojima.com/small_list/?topics_group_id=4&group=2&order_type=2"
GetPage(url)
}