Example #1
0
func NewSurfer(useCookie bool, paseTime time.Duration, proxy ...string) *Surfer {
	sf := surfer.New()
	if len(proxy) != 0 {
		sf.SetProxy(proxy[0])
	}

	return &Surfer{
		download: sf,
	}
}
Example #2
0
import (
	"net/http"

	"github.com/henrylee2cn/pholcus/app/downloader/context"
	"github.com/henrylee2cn/pholcus/config"
	"github.com/henrylee2cn/surfer"
)

type Surfer struct {
	surf    surfer.Surfer
	phantom surfer.Surfer
}

var SurferDownloader = &Surfer{
	surf:    surfer.New(),
	phantom: surfer.NewPhantom(config.SURFER_PHANTOM.FULL_APP_NAME, config.SURFER_PHANTOM.FULL_TEMP_JS),
}

func (self *Surfer) Download(cReq *context.Request) *context.Response {
	cResp := context.NewResponse(nil)

	var resp *http.Response
	var err error

	if cReq.GetUsePhantomJS() {
		resp, err = self.phantom.Download(cReq)
	} else {
		resp, err = self.surf.Download(cReq)
	}
Example #3
0
package downloader

import (
	"github.com/henrylee2cn/pholcus/app/downloader/context"
	"github.com/henrylee2cn/surfer"
)

type Surfer struct {
	download surfer.Surfer
}

var SurferDownloader = &Surfer{
	download: surfer.New(),
}

func (self *Surfer) Download(cReq *context.Request) *context.Response {
	cResp := context.NewResponse(nil)

	resp, err := self.download.Download(cReq)

	cResp.SetRequest(cReq)

	cResp.SetResponse(resp)

	cResp.SetError(err)

	return cResp
}
Example #4
0
package example

import (
	"github.com/henrylee2cn/surfer"
	"net/http"
)

var SurfDownloader = surfer.New()

func SurfDownload(req *Request) (*http.Response, error) {
	return SurfDownloader.Download(req)
}
Example #5
0
func NewSurfer() *Surfer {
	return &Surfer{
		download: surfer.New(),
	}
}