antchfx / htmlquery

htmlquery is golang XPath package for HTML query.
https://github.com/antchfx/xpath
MIT License
723 stars 73 forks source link

[Runtime error] - invalid memory address or nil pointer dereference #29

Closed imthaghost closed 4 years ago

imthaghost commented 4 years ago

Screen Shot 2020-05-07 at 12 48 04 PM

How to replicate


XPath := "//*[@id=\"market-summary\"]/div[2]/div/div[1]/div[1]"

doc, err := htmlquery.LoadURL("https://stockx.com/air-jordan-1-retro-high-off-white-university-blue")
if err != nil {
panic(err)
}

s2 := htmlquery.FindOne(doc, XPath)

p := string(htmlquery.InnerText(s2))

return p
zhengchun commented 4 years ago

I tested and can works on the latest version of htmlquery. Update the htmlquery dependency package xpath to the latest version 1.1.6