Git Product home page Git Product logo

Comments (3)

mna avatar mna commented on September 25, 2024

Will it be "root, _ := html.Parse(res.Body)" wrong here ?

Is it? Because it looks like it fails on the html node being nil.

Otherwise, if you can send me the html document as returned from res.Body, that would help to try and find the problem.

from goquery.

avelino avatar avelino commented on September 25, 2024

@PuerkitoBio example return error

doc, err := goquery.NewDocument("https://gist.githubusercontent.com/avelino/a4a8527f76d7eb14b2acb1e761c69b30/raw/98b1040bd1b5a09287b378f0327c37449ba0f5f5/test.html")
if err != nil {
    log.Println(err)
}
val, _ := doc.Find("meta[name=\"twitter:image\"]").Attr("content")

Error:

2016/04/30 03:48:40 unexpected EOF
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x59657f]

goroutine 1 [running]:
panic(0x8f9ca0, 0xc82000e260)
        /usr/lib/go/src/runtime/panic.go:481 +0x3e6
shelfgit.com/poorny/spider/providers/feeds.UnmarshalXML(0xc82013c150, 0x2c, 0xc82013c2d0, 0x29, 0xc82008c5a0, 0x118, 0x0, 0x0, 0x0, 0x0, ...)
        /home/avelino/projects/go/src/shelfgit.com/poorny/spider/providers/feeds/feeds.go:74 +0x5af
shelfgit.com/poorny/spider/providers.FeedByBot()
        /home/avelino/projects/go/src/shelfgit.com/poorny/spider/providers/providers.go:173 +0xf35
shelfgit.com/poorny/spider/providers.Switch(0xc82000a5d0, 0x1, 0x1)
        /home/avelino/projects/go/src/shelfgit.com/poorny/spider/providers/providers.go:107 +0x1466
main.main.func1(0xc820138000)
        /home/avelino/projects/go/src/shelfgit.com/poorny/spider/main.go:22 +0x103
github.com/codegangsta/cli.(*App).Run(0xc820134000, 0xc82000a5c0, 0x2, 0x2, 0x0, 0x0)
        /home/avelino/projects/go/src/github.com/codegangsta/cli/app.go:163 +0xbfc
main.main()
        /home/avelino/projects/go/src/shelfgit.com/poorny/spider/main.go:25 +0x163
exit status 2

from goquery.

mna avatar mna commented on September 25, 2024

I ran the goquery-related code snippet, it works fine and returns http://www.ovelhotarado.com/media/videos/tmb/11097/1.jpg for val.

Please don't comment on old closed issues, open a new one instead - but first try to isolate the problem and make sure it is related to this project. From your panic's stacktrace, it looks like it happens in the poorny/spider/providersfeeds package, goquery doesn't appear in the trace. Make sure you check all errors.

HTH,
Martin

from goquery.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.