chideat/go-phantomjs

Can you provide any example?

Closed this issue · 1 comments

Can you provide any example?
package main

import (
	driver "github.com/chideat/go-phantomjs"
	"log"
)

func main() {
	options := &driver.Options{}
	phantomJS, err := driver.NewPhantomJS(0, options)
	if err != nil {
		log.Fatal(err)
	}

	session, err := phantomJS.NewSession(&driver.Capabilities{})
	if err != nil {
		log.Fatal(err)
	}

	err = session.Get("https://google.com.br")
	if err != nil {
		log.Fatal(err)
	}

	var body string
	body, err = session.GetPageSource()
	if err != nil {
		log.Fatal(err)
	}

	log.Println(body)
	session.Close()

	err = phantomJS.Quit()
	if err != nil {
		log.Fatal(err)
	}
}