Make HTTP requests with cookies from your browsers!
This is a Go port of richardpenman's browsercookie.
- FireFox
- Chrome
package main
import (
"fmt"
"io/ioutil"
"net/http"
"regexp"
"github.com/aisk/browsercookies"
)
func main() {
jar, err := browsercookies.LoadFireFox()
if err != nil {
panic(err)
}
httpclient := http.Client{Jar: jar}
resp, err := httpclient.Get("https://github.com/settings/profile")
if err != nil {
panic(err)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
re := regexp.MustCompile(`<meta name="user-login" content="(\w*?)">`)
fmt.Println(re.FindAllStringSubmatch(string(body), -1)[0][1]) // => aisk
}
LGPL