Speed up removeUnlikelyCandidates
`.Not` returns a brand new Selection, copied element by element.
This commit is contained in:
parent
ab85d4d678
commit
347740dce1
1 changed files with 4 additions and 1 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue