Module grab.base

Here is the heart of the library, the Grab class.

class grab.base.Grab(document_body=None, transport=None, **kwargs)[source]
__init__(document_body=None, transport=None, **kwargs)[source]

Create Grab instance

setup_transport(transport_param, reset=False)[source]
reset()[source]

Reset all attributes which could be modified during previous request or which is not initialized yet if this is the new Grab instance.

This methods is automatically called before each network request.

clone(**kwargs)[source]

Create clone of Grab instance.

Cloned instance will have the same state: cookies, referrer, response document data

Parameters:**kwargs

overrides settings of cloned grab instance

adopt(grab)[source]

Copy the state of another Grab instance.

Use case: create backup of current state to the cloned instance and then restore the state from it.

dump_config()[source]

Make clone of current config.

load_config(config)[source]

Configure grab instance with external config object.

setup(**kwargs)[source]

Setting up Grab instance configuration.

go(url, **kwargs)[source]

Go to url

Args:
url:could be absolute or relative. If relative then t will be

appended to the absolute URL of previous request.

download(url, location, **kwargs)[source]

Fetch document located at url and save to to location.

request(**kwargs)[source]

Perform network request.

You can specify grab settings in **kwargs. Any keyword argument will be passed to self.config.

Returns: Document objects.

fake_response(*args, **kwargs)
load_proxylist(source, source_type, proxy_type='http', auto_init=True, auto_change=True)
change_proxy(random=True)[source]

Set random proxy from proxylist.

make_url_absolute(url, resolve_base=False)[source]

Make url absolute using previous request url as base url.

clear_cookies()[source]

Clear all remembered cookies.

load_cookies(path, file_required=None)
dump_cookies(path)
setup_with_proxyline(line, proxy_type='http')[source]
grab.base.BaseGrab

alias of grab.base.Grab