// return the comment within the sentence func getComment(sel *goquery.Selection) (string, map[int]string) { var contentBuffer bytes.Buffer var linksMap map[int]string = make(map[int]string) // fmt.Println(sel.Contents().Length()) sel.Contents().Each(func(i int, x *goquery.Selection) { href, exists := x.Attr("href") if exists { // this is a comment link link := getLink(href) commentNo, _ := strconv.Atoi(x.Text()) linksMap[commentNo] = link //fmt.Println(commentNo + ": " + link) } else { contentBuffer.WriteString(x.Text()) //fmt.Println(x.Text()) } }) return contentBuffer.String(), linksMap }
// contents returns a string representation of the selection's contents. func contents(s *goquery.Selection) string { return strings.Join(s.Contents().Map(node), "") }
func NumberOfChild(s *goquery.Selection) int { return s.Contents().Length() //return s.Contents().Size() }