User Agent

Set the user agent this browser instance will send with each request.

bow := surf.NewBrowser()

Or set the user agent globally so every new browser you create uses it.

browser.DefaultUserAgent = "SuperCrawler/1.0"


Attributes control how the browser behaves. Use the SetAttribute() method to set attributes one at a time.

bow := surf.NewBrowser()
bow.SetAttribute(browser.SendReferer, false)
bow.SetAttribute(browser.MetaRefreshHandling, false)
bow.SetAttribute(browser.FollowRedirects, false)

Or set the attributes all at once using SetAttributes().

bow := surf.NewBrowser()
    browser.SendReferer:         surf.DefaultSendReferer,
    browser.MetaRefreshHandling: surf.DefaultMetaRefreshHandling,
    browser.FollowRedirects:     surf.DefaultFollowRedirects,

The attributes can also be set globally. Now every new browser you create will be set with these defaults.

surf.DefaultSendReferer = false
surf.DefaultMetaRefreshHandling = false
surf.DefaultFollowRedirects = false

Storage Jars

Override the build in cookie jar. Surf uses cookiejar.Jar by default.

bow := surf.NewBrowser()

Override the build in bookmarks jar. Surf uses jar.MemoryBookmarks by default.

bow := surf.NewBrowser()

Use jar.FileBookmarks to read and write your bookmarks to a JSON file.

bookmarks, err = jar.NewFileBookmarks("/home/joe/bookmarks.json")
if err != nil { panic(err) }
bow := surf.NewBrowser()