示例#1
0
func newDefaultTestBrowser() *Browser {
	bow := &Browser{}
	bow.SetUserAgent(agent.Create())
	bow.SetState(&jar.State{})
	bow.SetCookieJar(jar.NewMemoryCookies())
	bow.SetBookmarksJar(jar.NewMemoryBookmarks())
	bow.SetHistoryJar(jar.NewMemoryHistory())
	bow.SetHeadersJar(jar.NewMemoryHeaders())
	bow.SetAttributes(AttributeMap{
		SendReferer:         true,
		MetaRefreshHandling: true,
		FollowRedirects:     true,
	})
	return bow
}
示例#2
0
文件: browser.go 项目: emgfc/surf
func NewBrowser() *Browser {
	bow := &Browser{}

	bow.client = &http.Client{
		Jar:           bow.cookies,
		CheckRedirect: bow.shouldRedirect,
	}

	bow.SetUserAgent(DefaultUserAgent)
	bow.SetState(&jar.State{})
	bow.SetCookieJar(jar.NewMemoryCookies())
	bow.SetBookmarksJar(jar.NewMemoryBookmarks())
	bow.SetHistoryJar(jar.NewMemoryHistory())
	bow.SetHeadersJar(jar.NewMemoryHeaders())
	bow.SetAttributes(AttributeMap{
		SendReferer:         DefaultSendReferer,
		MetaRefreshHandling: DefaultMetaRefreshHandling,
		FollowRedirects:     DefaultFollowRedirects,
	})

	return bow
}