func New() Surfer { return &Surf{ userAgents: agent.UserAgents, useCookie: true, cookieJar: jar.NewCookiesMemory(), sendReferer: true, followRedirect: true, tryTimes: 3, paseTime: 0, proxy: "", } }
// "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 }
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: "", } }