Module Expr Str Import alias Import alias Import alias Import alias Import alias Import alias Import alias ClassDef bases AttributeLoad NameLoad attr body Expr Str Assign NameStore Dict Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str Str AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore ListLoad Str Str Str Assign NameStore ListLoad Str Str Str Str Assign NameStore ListLoad Str Str Str Str Str Str Str Str Str Str If Call NameLoad NameLoad Str body Assign SubscriptStore NameLoad Index Str AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Str FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore AttributeStore NameLoad attr Dict For NameStore BinOpAdd BinOpAdd AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr body Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad Assign SubscriptStore NameLoad Index NameLoad Call NameLoad For NameStore Call AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad If CompareIn Str NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad If CompareIn Str NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore NameStore NameLoad If BoolOpOr CompareIn Str NameLoad CompareIn Str NameLoad body Assign NameStore Call AttributeLoad NameLoad attr If BoolOpOr CompareIn Str NameLoad CompareIn Str NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr NameLoad If CompareIn Str NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Dict For NameStore NameLoad body If Call AttributeLoad NameLoad attr Str body Raise Call NameLoad BinOpMod Str NameLoad If CompareNotIn NameLoad AttributeLoad NameLoad attr body Raise Call NameLoad Str Assign SubscriptStore NameLoad Index NameLoad NameLoad For TupleStore NameStore NameStore Call AttributeLoad AttributeLoad NameLoad attr attr body If Call AttributeLoad NameLoad attr Str body Continue If CompareNotIn NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad orelse Delete SubscriptDel NameLoad Index NameLoad For NameStore Call AttributeLoad NameLoad attr body Expr Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Str keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Str keyword NameLoad Expr Call AttributeLoad NameLoad attr Str keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign AttributeStore NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Str keyword NameLoad Expr Call AttributeLoad NameLoad attr Str keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign AttributeStore NameLoad attr NameLoad Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index Str Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Expr Call AttributeLoad NameLoad attr Str NameLoad keyword Dict Str Str NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str If CompareIsNot NameLoad NameLoad body Assign NameStore Dict Str NameLoad orelse Assign NameStore Dict Expr Call AttributeLoad NameLoad attr Str NameLoad keyword NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str If NameLoad body Expr Call AttributeLoad NameLoad attr Str keyword Num Expr Call AttributeLoad NameLoad attr Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Expr Call AttributeLoad NameLoad attr Str NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad Call NameLoad NameLoad For NameStore TupleLoad Str Str body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If CompareIsNot NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad TupleLoad Dict body If CompareIs NameLoad NameLoad body Assign NameStore CompareIsNot NameLoad NameLoad If NameLoad body Assign NameStore SubscriptLoad AttributeLoad NameLoad attr Index NameLoad If CompareIsNot NameLoad NameLoad body Assign NameStore Call NameLoad NameLoad orelse Assign NameStore Call NameLoad NameLoad NameLoad orelse Assign NameStore NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body If CompareIsNot NameLoad NameLoad body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad If NameLoad body TryExcept body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad handlers ExceptHandler type NameLoad body Pass If CompareIsNot NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index NameLoad NameLoad decorator_list decorator_list ClassDef bases NameLoad body FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign AttributeStore NameLoad attr Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults NameLoad AttributeLoad NameLoad attr body If AttributeLoad NameLoad attr body FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad AttributeLoad NameLoad attr body Return Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad decorator_list Assign NameStore Call AttributeLoad NameLoad attr NameLoad AttributeLoad NameLoad attr NameLoad NameLoad NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad Return NameLoad decorator_list decorator_list
N/A N/A Convenient HTTP UserAgent class.

This is a subclass of urllib2.OpenerDirector.


Copyright 2003-2006 John J. Lee <jjl@pobox.com>

This code is free software; you can redistribute it and/or modify it under
the terms of the BSD or ZPL 2.1 licenses (see the file COPYING.txt
included with the distribution).

 N/A warnings N/A _auth N/A _gzip N/A _opener N/A _response N/A _sockettimeout N/A _urllib2 UserAgentBase N/A N/A _opener OpenerDirector N/A N/A Convenient user-agent class.

    Do not use .add_handler() to add a handler for something already dealt with
    by this code.

    The only reason at present for the distinction between UserAgent and
    UserAgentBase is so that classes that depend on .seek()able responses
    (e.g. mechanize.Browser) can inherit from UserAgentBase.  The subclass
    UserAgent exposes a .set_seekable_responses() method that allows switching
    off the adding of a .seek() method to responses.

    Public attributes:

    addheaders: list of (name, value) pairs specifying headers to send with
     every request, unless they are overridden in the Request instance.

     >>> ua = UserAgentBase()
     >>> ua.addheaders = [
     ...  ("User-agent", "Mozilla/5.0 (compatible)"),
     ...  ("From", "responsible.person@example.com")]

     N/A handler_classes N/A http ftp file _unknown _http_error _http_request_upgrade _http_default_error _basicauth _digestauth _redirect _cookies _refresh _equiv _proxy _proxy_basicauth _proxy_digestauth _robots _gzip _debug_redirect _debug_response_body N/A _urllib2 HTTPHandler N/A _urllib2 FTPHandler N/A _urllib2 FileHandler N/A _urllib2 UnknownHandler N/A _urllib2 HTTPErrorProcessor N/A _urllib2 HTTPRequestUpgradeProcessor N/A _urllib2 HTTPDefaultErrorHandler N/A _urllib2 HTTPBasicAuthHandler N/A _urllib2 HTTPDigestAuthHandler N/A _urllib2 HTTPRedirectHandler N/A _urllib2 HTTPCookieProcessor N/A _urllib2 HTTPRefreshProcessor N/A _urllib2 HTTPEquivProcessor N/A _urllib2 ProxyHandler N/A _urllib2 ProxyBasicAuthHandler N/A _urllib2 ProxyDigestAuthHandler N/A _urllib2 HTTPRobotRulesProcessor N/A _gzip HTTPGzipProcessor N/A _urllib2 HTTPRedirectDebugProcessor N/A _urllib2 HTTPResponseDebugProcessor N/A default_schemes N/A http ftp file N/A default_others N/A _unknown _http_error _http_request_upgrade _http_default_error N/A default_features N/A _redirect _cookies _refresh _equiv _basicauth _digestauth _proxy _proxy_basicauth _proxy_digestauth _robots N/A N/A hasattr _urllib2 HTTPSHandler N/A N/A N/A handler_classes N/A https N/A _urllib2 HTTPSHandler N/A N/A N/A default_schemes append https __init__ N/A N/A self N/A N/A N/A N/A N/A N/A _opener OpenerDirector __init__ self N/A ua_handlers N/A self _ua_handlers N/A N/A scheme N/A N/A N/A self default_schemes N/A self default_others N/A self default_features N/A N/A klass N/A N/A self handler_classes N/A scheme N/A N/A ua_handlers N/A scheme N/A klass N/A handler N/A N/A ua_handlers itervalues N/A N/A N/A N/A self add_handler handler N/A N/A _refresh ua_handlers N/A N/A N/A N/A self set_handle_refresh True N/A N/A _equiv ua_handlers N/A N/A N/A N/A self set_handle_equiv True N/A pm ppm None N/A N/A N/A _basicauth ua_handlers N/A _digestauth ua_handlers N/A N/A pm N/A N/A _urllib2 HTTPPasswordMgrWithDefaultRealm N/A N/A N/A _proxy_basicauth ua_handlers N/A _proxy_digestauth ua_handlers N/A N/A ppm N/A N/A _auth HTTPProxyPasswordMgr N/A N/A N/A self set_password_manager pm N/A N/A N/A self set_proxy_password_manager ppm N/A N/A https ua_handlers N/A N/A cm N/A N/A _urllib2 HTTPSClientCertMgr N/A N/A N/A self set_client_cert_manager cm N/A close N/A N/A self N/A N/A N/A N/A N/A N/A _opener OpenerDirector close self N/A N/A self _ua_handlers None N/A set_handled_schemes N/A N/A self schemes N/A N/A N/A Set sequence of URL scheme (protocol) strings.

        For example: ua.set_handled_schemes(["http", "ftp"])

        If this fails (with ValueError) because you've passed an unknown
        scheme, the set of handled schemes will not be changed.

         N/A want N/A N/A scheme schemes N/A N/A N/A N/A scheme startswith _ N/A N/A N/A ValueError N/A not a scheme '%s' scheme N/A N/A scheme N/A self handler_classes N/A N/A N/A ValueError unknown scheme '%s' N/A N/A want N/A scheme None N/A N/A scheme oldhandler N/A N/A N/A self _ua_handlers items N/A N/A N/A N/A scheme startswith _ N/A N/A N/A N/A scheme want N/A N/A N/A N/A self _replace_handler scheme None N/A N/A N/A want N/A scheme N/A scheme N/A N/A want keys N/A N/A N/A N/A self _set_handler scheme True N/A set_cookiejar N/A N/A self cookiejar N/A N/A N/A Set a mechanize.CookieJar, or None. N/A N/A N/A self _set_handler _cookies obj cookiejar N/A set_proxies N/A N/A self proxies N/A N/A N/A Set a dictionary mapping URL scheme to proxy specification, or None.

        e.g. {"http": "joe:password@myproxy.example.com:3128",
              "ftp": "proxy.example.com"}

         N/A N/A N/A self _set_handler _proxy obj proxies N/A add_password N/A N/A self url user password realm N/A None N/A N/A N/A N/A N/A self _password_manager add_password realm url user password N/A add_proxy_password N/A N/A self user password hostport realm N/A None None N/A N/A N/A N/A N/A self _proxy_password_manager add_password realm hostport user password N/A add_client_certificate N/A N/A self url key_file cert_file N/A N/A N/A Add an SSL client certificate, for HTTPS client auth.

        key_file and cert_file must be filenames of the key and certificate
        files, in PEM format.  You can use e.g. OpenSSL to convert a p12 (PKCS
        12) file to PEM format:

        openssl pkcs12 -clcerts -nokeys -in cert.p12 -out cert.pem
        openssl pkcs12 -nocerts -in cert.p12 -out key.pem


        Note that client certificate password input is very inflexible ATM.  At
        the moment this seems to be console only, which is presumably the
        default behaviour of libopenssl.  In future mechanize may support
        third-party libraries that (I assume) allow more options here.

         N/A N/A N/A N/A self _client_cert_manager add_key_cert url key_file cert_file N/A set_password_manager N/A N/A self password_manager N/A N/A N/A Set a mechanize.HTTPPasswordMgrWithDefaultRealm, or None. N/A N/A self _password_manager password_manager N/A N/A N/A self _set_handler _basicauth obj password_manager N/A N/A N/A self _set_handler _digestauth obj password_manager N/A set_proxy_password_manager N/A N/A self password_manager N/A N/A N/A Set a mechanize.HTTPProxyPasswordMgr, or None. N/A N/A self _proxy_password_manager password_manager N/A N/A N/A self _set_handler _proxy_basicauth obj password_manager N/A N/A N/A self _set_handler _proxy_digestauth obj password_manager N/A set_client_cert_manager N/A N/A self cert_manager N/A N/A N/A Set a mechanize.HTTPClientCertMgr, or None. N/A N/A self _client_cert_manager cert_manager N/A handler N/A N/A self _ua_handlers N/A https N/A N/A handler client_cert_manager cert_manager N/A set_handle_robots N/A N/A self handle N/A N/A N/A Set whether to observe rules from robots.txt. N/A N/A N/A self _set_handler _robots handle N/A set_handle_redirect N/A N/A self handle N/A N/A N/A Set whether to handle HTTP 30x redirections. N/A N/A N/A self _set_handler _redirect handle N/A set_handle_refresh N/A N/A self handle max_time honor_time N/A None True N/A N/A Set whether to handle HTTP Refresh headers. N/A N/A N/A self _set_handler _refresh handle constructor_kwds N/A max_time honor_time max_time honor_time N/A set_handle_equiv N/A N/A self handle head_parser_class N/A None N/A N/A Set whether to treat HTML http-equiv headers like HTTP headers.

        Response objects may be .seek()able if this is set (currently returned
        responses are, raised HTTPError exception responses are not).

         N/A N/A head_parser_class None N/A N/A constructor_kwds N/A head_parser_class head_parser_class N/A N/A constructor_kwds N/A N/A N/A N/A self _set_handler _equiv handle constructor_kwds constructor_kwds N/A set_handle_gzip N/A N/A self handle N/A N/A N/A Handle gzip transfer encoding.

         N/A handle N/A N/A N/A N/A warnings warn gzip transfer encoding is experimental! stacklevel 2 N/A N/A N/A self _set_handler _gzip handle N/A set_debug_redirects N/A N/A self handle N/A N/A N/A Log information about HTTP redirects (including refreshes).

        Logging is performed using module logging.  The logger name is
        "mechanize.http_redirects".  To actually print some debug output,
        eg:

        import sys, logging
        logger = logging.getLogger("mechanize.http_redirects")
        logger.addHandler(logging.StreamHandler(sys.stdout))
        logger.setLevel(logging.INFO)

        Other logger names relevant to this module:

        "mechanize.http_responses"
        "mechanize.cookies" (or "cookielib" if running Python 2.4)

        To turn on everything:

        import sys, logging
        logger = logging.getLogger("mechanize")
        logger.addHandler(logging.StreamHandler(sys.stdout))
        logger.setLevel(logging.INFO)

         N/A N/A N/A self _set_handler _debug_redirect handle N/A set_debug_responses N/A N/A self handle N/A N/A N/A Log HTTP response bodies.

        See docstring for .set_debug_redirects() for details of logging.

        Response objects may be .seek()able if this is set (currently returned
        responses are, raised HTTPError exception responses are not).

         N/A N/A N/A self _set_handler _debug_response_body handle N/A set_debug_http N/A N/A self handle N/A N/A N/A Print HTTP headers to sys.stdout. N/A level N/A int N/A bool handle N/A scheme N/A http https N/A N/A h N/A N/A N/A self _ua_handlers get scheme N/A N/A h None N/A N/A N/A N/A h set_http_debuglevel level N/A _set_handler N/A N/A self name handle obj constructor_args constructor_kwds N/A None None N/A N/A N/A N/A N/A handle None N/A N/A handle N/A obj None N/A handle N/A N/A handler_class N/A N/A self handler_classes N/A name N/A N/A obj None N/A N/A newhandler N/A handler_class obj N/A N/A newhandler N/A handler_class constructor_args constructor_kwds N/A N/A newhandler None N/A N/A N/A self _replace_handler name newhandler N/A _replace_handler N/A N/A self name newhandler N/A None N/A N/A N/A name None N/A N/A handler N/A N/A N/A self _ua_handlers get name N/A handler N/A N/A N/A N/A N/A N/A N/A self handlers remove handler N/A N/A N/A ValueError N/A N/A N/A N/A newhandler None N/A N/A N/A N/A self add_handler newhandler N/A N/A N/A self _ua_handlers N/A name newhandler N/A N/A UserAgent N/A UserAgentBase N/A __init__ N/A N/A self N/A N/A N/A N/A N/A UserAgentBase __init__ self N/A N/A self _seekable False N/A set_seekable_responses N/A N/A self handle N/A N/A N/A Make response objects .seek()able. N/A N/A self _seekable N/A bool handle N/A open N/A N/A self fullurl data timeout N/A None N/A _sockettimeout _GLOBAL_DEFAULT_TIMEOUT N/A N/A N/A self _seekable N/A bound_open N/A N/A fullurl data timeout N/A None N/A _sockettimeout _GLOBAL_DEFAULT_TIMEOUT N/A N/A N/A N/A UserAgentBase open self fullurl data timeout N/A N/A response N/A N/A _opener wrapped_open bound_open N/A _response seek_wrapped_response fullurl data timeout N/A N/A response N/A N/A UserAgentBase open self fullurl data N/A response N/A N/A