Setting up the Grab Request

To set up specific parameters of a network request you need to build the Grab object and configure it. You can do both things at the same time:

g = Grab(url='', method='head', timeout=10)

Or you can build the Grab object with some initial settings and configure it later:

g = Grab(timeout=10)
g.setup(url='', method='head')

Also you can pass settings as parameters to request or go:

g = Grab(timeout=10)
# OR

request and go are almost same except for one small thing. You do not need to specify the explicit name of the first argument with go. The first argument of the go method is always url. Except for this, all other named arguments of go and request are just passed to the setup function.

For a full list of available settings you can check Grab Settings

Grab Config Object

Every time you configure a Grab instance, all options are saved in the special object, grab.config, that holds all Grab instance settings. You can receive a copy of the config object and also you can setup a Grab instance with the config object:

>>> g = Grab(url='')
>>> g.config['url']
>>> config = g.dump_config()
>>> g2 = Grab()
>>> g2.load_config(config)
>>> g2.config['url']

The Grab config object is simply a dict object. Some of the values may also be a dict.

Grab Instance Cloning

If you need to copy a Grab object there is a more elegant way than using the dump_config and load_config methods:

g2 = g1.clone()

g2 gets the same state as g1. In particular, g2 will have the same cookies.