mechanize

package module
v0.0.0-...-7f112ee Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2015 License: MIT Imports: 12 Imported by: 0

README

go-mechanize

Build Status

WARNING: EXTREME ALPHA QUALITY CODE

Package mechanize implements Perl5's WWW::Mechanize style HTTP client that mimics a real web browser, in terms of resolving relative URLs and such.

If you need a working tool right now, please check out surf. This library exists because I had some itches that I wanted to scratch.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func FollowRedirectsCallback

func FollowRedirectsCallback(howmany int) func(r *http.Request, via []*http.Request) error

FollowRedirectsCallback is a function to be passed to http.Client 's CheckRedirect callback, allowing all redirects, up to m.MaxRedirects

Types

type Form

type Form struct {
	*html.Node
	// contains filtered or unexported fields
}

func NewForm

func NewForm(m *Mechanize, n *html.Node) *Form

func (*Form) FindField

func (f *Form) FindField(name string) (FormField, error)

func (*Form) FormValues

func (f *Form) FormValues() (url.Values, error)

func (*Form) SetValue

func (f *Form) SetValue(name, value string) error

func (*Form) Submit

func (f *Form) Submit() error

type FormField

type FormField interface {
	RawNode() *html.Node
	Name() string
	Value() string
	SetValue(string)
}

type Input

type Input struct {
	*html.Node
}

func NewInput

func NewInput(n *html.Node) *Input

func (Input) Name

func (i Input) Name() string

func (Input) RawNode

func (i Input) RawNode() *html.Node

func (*Input) SetValue

func (i *Input) SetValue(v string)

func (Input) Value

func (i Input) Value() string

type Mechanize

type Mechanize struct {
	Agent       string
	Client      *http.Client
	CookieJar   *cookiejar.Jar
	Headers     http.Header
	SendReferer bool
	// contains filtered or unexported fields
}
Example
{
}
Output:

func New

func New() *Mechanize

func (*Mechanize) BuildRequest

func (m *Mechanize) BuildRequest(method, u string, body io.Reader) (*http.Request, error)

func (*Mechanize) Get

func (m *Mechanize) Get(u string) error

func (*Mechanize) Head

func (m *Mechanize) Head(u string) error

func (*Mechanize) LastError

func (m *Mechanize) LastError() error

func (*Mechanize) LastRequest

func (m *Mechanize) LastRequest() *http.Request

LastRequest returns the most recent *http.Request. If there are no request/response recorded, then the this method returns nil

func (*Mechanize) LastResponse

func (m *Mechanize) LastResponse() *Response

LastResponse returns the most recent *Response. If there are no request/response recorded, then the this method returns nil

func (*Mechanize) Post

func (m *Mechanize) Post(u string, bodyType string, body io.Reader) error

func (*Mechanize) PostForm

func (m *Mechanize) PostForm(u string, data url.Values) error

func (*Mechanize) ResolveURL

func (m *Mechanize) ResolveURL(u *url.URL) *url.URL

func (*Mechanize) SendRequest

func (m *Mechanize) SendRequest(req *http.Request) error

func (*Mechanize) SetMaxRedirects

func (m *Mechanize) SetMaxRedirects(howmany int)

type Response

type Response struct {
	*http.Response
	// contains filtered or unexported fields
}

func NewResponse

func NewResponse(m *Mechanize, res *http.Response) *Response

func (*Response) Base

func (r *Response) Base() string

func (*Response) Form

func (r *Response) Form(sel string) (*Form, error)

func (*Response) Forms

func (r *Response) Forms() []*Form

func (*Response) IsClientError

func (r *Response) IsClientError() bool

func (*Response) IsError

func (r *Response) IsError() bool

func (*Response) IsHTML

func (r *Response) IsHTML() bool

func (*Response) IsRedirect

func (r *Response) IsRedirect() bool

func (*Response) IsSuccess

func (r *Response) IsSuccess() bool

func (*Response) RawBody

func (r *Response) RawBody() []byte

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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