feat(sources): add managed RSS feeds (#41)
This commit is contained in:
34
backend/internal/scraper/quanwenrss/access.go
Normal file
34
backend/internal/scraper/quanwenrss/access.go
Normal file
@ -0,0 +1,34 @@
|
||||
package quanwenrss
|
||||
|
||||
import (
|
||||
"golang.org/x/net/html"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Restriction evidence is inspected before presentation chrome is removed.
|
||||
func bodyRestricted(raw string) bool {
|
||||
t := html.NewTokenizer(strings.NewReader(raw))
|
||||
for {
|
||||
kind := t.Next()
|
||||
if kind == html.ErrorToken {
|
||||
return false
|
||||
}
|
||||
if kind != html.StartTagToken && kind != html.SelfClosingTagToken {
|
||||
continue
|
||||
}
|
||||
token := t.Token()
|
||||
for _, a := range token.Attr {
|
||||
value := strings.ToLower(a.Val)
|
||||
if (a.Key == "data-content-state" && (value == "partial" || value == "incomplete")) || (a.Key == "data-content-truncated" && value == "true") || (a.Key == "data-accessible" && value == "false") {
|
||||
return true
|
||||
}
|
||||
if a.Key == "class" || a.Key == "id" || a.Key == "data-component" || a.Key == "data-testid" || a.Key == "data-test" || a.Key == "src" {
|
||||
for _, marker := range []string{"paywall", "giftarticle", "captcha", "challenge", "cf-chl", "placeholder", "skeleton", "truncated", "partial"} {
|
||||
if strings.Contains(value, marker) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user