Skip to content
A phantomjs wrapper for go
Go JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data
.gitignore
LICENSE
README.md
bindata.go
phantom.go
phantom_example_test.go
phantom_test.go

README.md

go-phantomjs

A tiny phantomjs wrapper for go

Usage

import (
  "github.com/urturn/go-phantomjs" // exported package is phantomjs
)

func main() {
  p, err := phantomjs.Start()
  if err != nil {
    panic(err)
  }
  defer p.Exit() // Don't forget to kill phantomjs at some point.
  var result interface{}
  err = p.Run("function() { return 2 + 2 }", &result)
  if err != nil {
    panic(err)
  }
  number, ok := result.(float64)
  if !ok {
    panic("Cannot convert result to float64")
  }
  fmt.Println(number)
  // Output: 4
}
You can’t perform that action at this time.