Code Monkey home page Code Monkey logo

go-htmlparser's People

Contributors

calbucci avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

go-htmlparser's Issues

runtime error: invalid memory address or nil pointer dereference

Please help, i cant seem to get the text in between title
In /app/models/prime.go (around line 50)

parser.Parse(func(toWrite string, element *goparser.HtmlElement) {

->>error here(line 50) if element.TagName == "title" {
theTitle.WriteString(toWrite)
}
}, func(element *goparser.HtmlElement, isEmptyTag bool) {

    if element.TagName == "meta" {
        ogName, _ := element.GetAttributeValue("property")
        simpleName, _ := element.GetAttributeValue("name")
        if simpleName=="description" {
        desc, _ := element.GetAttributeValue("content")
            fmt.Println(desc)
        }
        if ogName == "" || !strings.HasPrefix(ogName, "og:")  {
            return
        }
        ogValue, _ := element.GetAttributeValue("content")
        tags[ogName] = ogValue
    }
}, nil)

Call Stack

/root/go/src/myapp/app/models/prime.go:50 (0x67cc47)
ParseLink.func1: if element.TagName == "title" {
/root/go/src/github.com/calbucci/go-htmlparser/htmlparser.go:186 (0x77f9d8)
(_HtmlParser).callText: p.textCallback(text, parent)
/root/go/src/github.com/calbucci/go-htmlparser/htmlparser.go:268 (0x780b05)
(_HtmlParser).internalParse: hp.callText(text2, parent)
/root/go/src/github.com/calbucci/go-htmlparser/htmlparser.go:102 (0x77f295)
(_HtmlParser).Parse: parser.internalParse()
/root/go/src/myapp/app/models/prime.go:68 (0x67c745)
ParseLink: }, nil)
/root/go/src/myapp/app/controllers/app.go:38 (0x4ca87c)
App.Parse: jsonResult:=models.ParseLink(parseInfo);
:21 (0x4cb64b)
/usr/local/go/src/runtime/asm_amd64.s:437 (0x45ac3e)
call32: CALLFN(·call32, 32)
/usr/local/go/src/reflect/value.go:432 (0x470cfa)
Value.call: call(frametype, fn, args, uint32(frametype.size), uint32(retOffset))
/usr/local/go/src/reflect/value.go:300 (0x46f9c1)
Value.Call: return v.call("Call", in)
/root/work/src/github.com/revel/revel/invoker.go:36 (0x49568a)
/root/work/src/github.com/revel/revel/compress.go:47 (0x486fb2)
/root/work/src/github.com/revel/revel/intercept.go:103 (0x494362)
/root/go/src/myapp/app/init.go:37 (0x4c9cdf)
glob.func1: fc[0](c, fc[1:]) // Execute the next filter stage.
/root/work/src/github.com/revel/revel/i18n.go:155 (0x49364c)
/root/work/src/github.com/revel/revel/validation.go:191 (0x4ac7c6)
/root/work/src/github.com/revel/revel/flash.go:46 (0x48fdd0)
/root/work/src/github.com/revel/revel/session.go:149 (0x4a7785)
/root/work/src/github.com/revel/revel/params.go:133 (0x4978ef)
/root/work/src/github.com/revel/revel/filterconfig.go:208 (0x48f94d)
/root/work/src/github.com/revel/revel/router.go:474 (0x4a485f)
/root/work/src/github.com/revel/revel/panic.go:15 (0x495ae1)
/root/work/src/github.com/revel/revel/watcher.go:232 (0x4b3536)
/root/work/src/github.com/revel/revel/server.go:50 (0x4a53fe)
/root/work/src/github.com/revel/revel/server.go:38 (0x4a4f6f)
/usr/local/go/src/net/http/server.go:1422 (0x54ad7a)
HandlerFunc.ServeHTTP: f(w, r)
/usr/local/go/src/net/http/server.go:1862 (0x54cfee)
serverHandler.ServeHTTP: handler.ServeHTTP(rw, req)
/usr/local/go/src/net/http/server.go:1361 (0x54a83e)
(_conn).serve: serverHandler{c.server}.ServeHTTP(w, w.req)
/usr/local/go/src/runtime/asm_amd64.s:1696 (0x45cf61)
goexit: BYTE $0x90 // NOP

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.