From b308955ccfad8503269ac494982fff437a1c6ac7 Mon Sep 17 00:00:00 2001 From: Arya Kiran Date: Tue, 9 May 2023 17:45:33 +0530 Subject: [PATCH] add reaction support --- pages/release.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pages/release.go b/pages/release.go index 1d63b04..2ad08a3 100644 --- a/pages/release.go +++ b/pages/release.go @@ -31,9 +31,8 @@ type Assets struct { ReleasedOn string } type Reactions struct { - Name string - Count string - Reactants []string + Name string + Count string } func ReleaseView(c *fiber.Ctx) error { @@ -84,9 +83,17 @@ func ReleaseView(c *fiber.Ctx) error { } sc.OnHTML("div.Box-footer", func(e *colly.HTMLElement) { Scrape.AssetCount = e.ChildText("details summary span.Counter") + Scrape.TotalReactions = strings.TrimSuffix(e.ChildText("div.comment-reactions div.color-fg-muted"), " people reacted") e.ForEach("ul li", func(i int, el *colly.HTMLElement) { Scrape.Contributors = append(Scrape.Contributors, strings.TrimPrefix(el.ChildAttr("a img", "alt"), "@")) }) + e.ForEach("div.js-comment-reactions-options button", func(i int, el *colly.HTMLElement) { + Scrape.Reactions = append(Scrape.Reactions, Reactions{ + Name: el.ChildText("g-emoji"), + Count: el.ChildText("span.js-discussion-reaction-group-count"), + }) + }) + }) sc.Visit("https://github.com/" + c.Params("user") + "/" + c.Params("repo") + "/releases/" + c.Params("release")) // Add scrape-based info to releaseArray