browsercookies

package module
v0.0.0-...-b0089b4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2024 License: LGPL-2.1 Imports: 15 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chrome

type Chrome struct {
	http.CookieJar
}

Chrome is the cookie jar which loads all your cookies in FireFox.

type FireFox

type FireFox struct {
	http.CookieJar
}

FireFox is the cookie jar which loads all your cookies in FireFox.

func LoadChrome

func LoadChrome() (*FireFox, error)

LoadChrome will load all your cookies from FireFox.

func LoadFireFox

func LoadFireFox() (*FireFox, error)

LoadFireFox will load all your cookies from FireFox.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL