Skip to content

Instantly share code, notes, and snippets.

@angch
Created October 30, 2014 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angch/48ef8f13ceabccaa909f to your computer and use it in GitHub Desktop.
Save angch/48ef8f13ceabccaa909f to your computer and use it in GitHub Desktop.
Some snippet golang code for excalibr to retrieve/reuse sessions using cookies.
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/http/cookiejar"
"net/url"
)
func main() {
myUrlString := "http://store.steampowered.com/"
myCookies, _ := cookiejar.New(&cookiejar.Options{})
myBrowser := &http.Client{
Jar: myCookies,
}
resp, _ := myBrowser.Get(myUrlString)
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
fmt.Println("Cookies set:")
myUrl, _ := url.Parse(myUrlString)
for _, cookie := range myCookies.Cookies(myUrl) {
fmt.Println(cookie)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment