add reaction support

This commit is contained in:
Arya Kiran
2023-05-09 17:45:33 +05:30
parent a5324ccdca
commit b308955ccf
+10 -3
View File
@@ -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