Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 1.31 KB

README.md

File metadata and controls

57 lines (41 loc) · 1.31 KB

browsercookies

GoDoc Go Report Card Maintainability

Make HTTP requests with cookies from your browsers!

cookie jar

This is a Go port of richardpenman's browsercookie.


Supported browsers:

  • FireFox
  • Chrome

Example:

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
}

License:

LGPL