<noscript> causes selector to fail
Author: nathan-osmanCreated Dec 5, 2016Updated Jul 29, 2021
Consider the following program:
package main
import (
"fmt"
"strings"
"github.com/PuerkitoBio/goquery"
)
const data = `<noscript><a href="http://example.org">click this link</a></noscript>`
func main() {
d, err := goquery.NewDocumentFromReader(strings.NewReader(data))
if err != nil {
fmt.Println(err)
return
}
a, ok := d.Find("noscript a").Attr("href")
fmt.Printf("URL: '%s', %t\n", a, ok)
}The expected output is:
URL: 'http://example.org', trueBut instead the output is:
URL: '', falseChanging noscript to div in both the document and selector causes the expected output, so the problem seems to affect only <noscript> elements.
Source: PuerkitoBio/goquery