Esempio n. 1
0
func New() Surfer {
	return &Surf{
		userAgents:     agent.UserAgents,
		useCookie:      true,
		cookieJar:      jar.NewCookiesMemory(),
		sendReferer:    true,
		followRedirect: true,
		tryTimes:       3,
		paseTime:       0,
		proxy:          "",
	}
}
Esempio n. 2
0
// "true": static UserAgent/can cookie or "false": dynamic UserAgent/disable cookie
func (self *Surf) SetUseCookie(use bool) Surfer {
	self.useCookie = use
	if use {
		self.cookieJar = jar.NewCookiesMemory()
		l := len(self.userAgents["common"])
		r := rand.New(rand.NewSource(time.Now().UnixNano()))
		idx := r.Intn(l)
		self.userAgents["common"][0], self.userAgents["common"][idx] = self.userAgents["common"][idx], self.userAgents["common"][0]
	} else {
		self.cookieJar = nil
	}
	return self
}
Esempio n. 3
0
func New() Surfer {
	return &Surf{
		userAgents:     agent.UserAgents,
		useCookie:      true,
		cookieJar:      jar.NewCookiesMemory(),
		sendReferer:    true,
		followRedirect: true,
		tryTimes:       TryTimes,
		deadline:       Deadline,
		dialTimeout:    DialTimeout,
		pauseTime:      PauseTime,
		proxy:          "",
	}
}