Speed up removeUnlikelyCandidates

`.Not` returns a brand new Selection, copied element by element.
This commit is contained in:
jvoisin 2024-02-29 13:49:55 +01:00 committed by Frédéric Guillot
parent ab85d4d678
commit 347740dce1

View file

@ -137,7 +137,10 @@ func getArticle(topCandidate *candidate, candidates candidateList) string {
} }
func removeUnlikelyCandidates(document *goquery.Document) { func removeUnlikelyCandidates(document *goquery.Document) {
document.Find("*").Not("html,body").Each(func(i int, s *goquery.Selection) { document.Find("*").Each(func(i int, s *goquery.Selection) {
if s.Length() == 0 || s.Get(0).Data == "html" || s.Get(0).Data == "body" {
return
}
class, _ := s.Attr("class") class, _ := s.Attr("class")
id, _ := s.Attr("id") id, _ := s.Attr("id")
str := class + id str := class + id