go – use gocolly to get div element failed-ThrowExceptions

Exception or error:

i want get the price 2930.15 (follow red frame)

enter image description here

c.OnHTML("div[id=price]", func(e *colly.HTMLElement) {
        fmt.Printf("test----%+v\n",e)
        price,err := strconv.ParseFloat(e.Text,64)
        //price := e.Text
        fmt.Printf("********* price----%+v\n",price)

        if err != nil {

            fmt.Printf("parse err---%+v\n",err)

        }


    })

then print

test----&{Name:div Text:@now@ attributes:[{Namespace: Key:id Val:price} {Namespace: Key:class Val:@UD_change@}] Request:0xc00013c280 Response:0xc000354240 DOM:0xc000558180 Index:0}
********* price----0
parse err---strconv.ParseFloat: parsing "@now@": invalid syntax

how to do ? where i wrong?

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *