Module grab.base — Grab 0.6 documentation

# Module grab.base

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

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

    Create Grab instance

  setup_transport(transport_param, reset=False)
  reset()

    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)

    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)

    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()

    Make clone of current config.

  load_config(config)

    Configure grab instance with external config object.

  setup(**kwargs)

    Setting up Grab instance configuration.

  go(url, **kwargs)

    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)

    Fetch document located at `url` and save to to `location`.

  request(**kwargs)

    Perform network request.

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

    Returns: `Document` objects.

  change_proxy(random=True)

    Set random proxy from proxylist.

  make_url_absolute(url, resolve_base=False)

    Make url absolute using previous request url as base url.

  clear_cookies()

    Clear all remembered cookies.

  setup_with_proxyline(line, proxy_type='http')

grab.base.BaseGrab

  alias of `grab.base.Grab`