Skip to content

Commit

Permalink
template
Browse files Browse the repository at this point in the history
  • Loading branch information
kaki-admin committed Apr 26, 2024
1 parent bc93e09 commit 1ed7d52
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 0 deletions.
19 changes: 19 additions & 0 deletions templates/kotaku.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package templates

import (
"github.com/PuerkitoBio/goquery"
)

func (t *Template) KotakuScrapContent(document *goquery.Document) string {
contents := ""

document.Find("div.js_related-stories-inset,div.js_ad-dynamic,div.instream-native-video,div.js_related-stories-inset-mobile").Each(func(i int, s *goquery.Selection) {
RemoveNodes(s)
})
document.Find("div.js_post-content").Each(func(i int, s *goquery.Selection) {
var content string
content, _ = goquery.OuterHtml(s)
contents += content
})
return contents
}
20 changes: 20 additions & 0 deletions templates/microsoft.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package templates

import (
"github.com/PuerkitoBio/goquery"
)

func (t *Template) MicrosoftScrapContent(document *goquery.Document) string {
contents := ""

document.Find("header").Each(func(i int, s *goquery.Selection) {
RemoveNodes(s)

})
document.Find("article.m-blog-post").Each(func(i int, s *goquery.Selection) {
var content string
content, _ = goquery.OuterHtml(s)
contents += content
})
return contents
}
19 changes: 19 additions & 0 deletions templates/polygon.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package templates

import (
"github.com/PuerkitoBio/goquery"
)

func (t *Template) PolygonScrapContent(document *goquery.Document) string {
contents := ""

document.Find("aside,div.loopnav-a").Each(func(i int, s *goquery.Selection) {
RemoveNodes(s)
})
document.Find("figure.e-image--hero,div.c-entry-content").Each(func(i int, s *goquery.Selection) {
var content string
content, _ = goquery.OuterHtml(s)
contents += content
})
return contents
}
19 changes: 19 additions & 0 deletions templates/postExtractor/espn.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package postExtractor

import (
"strings"

"github.com/PuerkitoBio/goquery"
)

func (t PostExtractorTemplate) EspnPostExtractor(content, feedUrl string) string {
templateData := strings.NewReader(content)

doc, _ := goquery.NewDocumentFromReader(templateData)
doc.Find("header,figcaption").Each(func(i int, s *goquery.Selection) {
s.Remove()
})

newContent, _ := doc.Html()
return newContent
}
21 changes: 21 additions & 0 deletions templates/tvline.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package templates

import (
"github.com/PuerkitoBio/goquery"
)

func (t *Template) TVLineScrapContent(document *goquery.Document) string {
contents := ""

document.Find("div[data-component=social-media],div[data-component=cards-related-content]").Each(func(i int, s *goquery.Selection) {
RemoveNodes(s)

})

document.Find("div[data-component=featured-media],div[data-component=gutenberg-content]").Each(func(i int, s *goquery.Selection) {
var content string
content, _ = goquery.OuterHtml(s)
contents += content
})
return contents
}

0 comments on commit 1ed7d52

Please sign in to comment.