Python API

Generated from the Python source; no native library is imported during this build. Use the Python tutorial for runnable examples. Timeouts use seconds.

HTTP helpers

Helpers return a live Page with a private session. Close the page or use a context manager to release both. Use Session for shared cookies and session configuration.

brimp.request

request(method, url, **kwargs)

Request a live Page using a private session.

Keyword arguments are those of Page.request. Close the page or use it as a context manager to release both page and session. Use Session directly for session configuration or cookies shared between multiple pages.

Source code in brimp/__init__.py
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
def request(method, url, **kwargs):
    """Request a live Page using a private session.

    Keyword arguments are those of Page.request. Close the page or use it as a
    context manager to release both page and session. Use Session directly for
    session configuration or cookies shared between multiple pages.
    """
    session = Session()
    try:
        page = session.request(method, url, **kwargs)
        page._session_cleanup = weakref.finalize(page, session.close)
        return page
    except BaseException:
        session.close()
        raise

brimp.get

get(url, **kwargs)

GET a live Page. Accepts the keyword arguments of Page.request.

Source code in brimp/__init__.py
721
722
723
def get(url, **kwargs):
    """GET a live Page. Accepts the keyword arguments of Page.request."""
    return request("GET", url, **kwargs)

brimp.head

head(url, **kwargs)

HEAD a live Page. Accepts the keyword arguments of Page.request.

Source code in brimp/__init__.py
726
727
728
def head(url, **kwargs):
    """HEAD a live Page. Accepts the keyword arguments of Page.request."""
    return request("HEAD", url, **kwargs)

brimp.post

post(url, **kwargs)

POST a live Page. Accepts the keyword arguments of Page.request.

Source code in brimp/__init__.py
731
732
733
def post(url, **kwargs):
    """POST a live Page. Accepts the keyword arguments of Page.request."""
    return request("POST", url, **kwargs)

brimp.put

put(url, **kwargs)

PUT a live Page. Accepts the keyword arguments of Page.request.

Source code in brimp/__init__.py
736
737
738
def put(url, **kwargs):
    """PUT a live Page. Accepts the keyword arguments of Page.request."""
    return request("PUT", url, **kwargs)

brimp.patch

patch(url, **kwargs)

PATCH a live Page. Accepts the keyword arguments of Page.request.

Source code in brimp/__init__.py
741
742
743
def patch(url, **kwargs):
    """PATCH a live Page. Accepts the keyword arguments of Page.request."""
    return request("PATCH", url, **kwargs)

brimp.delete

delete(url, **kwargs)

DELETE a live Page. Accepts the keyword arguments of Page.request.

Source code in brimp/__init__.py
746
747
748
def delete(url, **kwargs):
    """DELETE a live Page. Accepts the keyword arguments of Page.request."""
    return request("DELETE", url, **kwargs)

brimp.options

options(url, **kwargs)

OPTIONS a live Page. Accepts the keyword arguments of Page.request.

Source code in brimp/__init__.py
751
752
753
def options(url, **kwargs):
    """OPTIONS a live Page. Accepts the keyword arguments of Page.request."""
    return request("OPTIONS", url, **kwargs)

brimp.trace

trace(url, **kwargs)

TRACE a live Page. Accepts the keyword arguments of Page.request.

Source code in brimp/__init__.py
756
757
758
def trace(url, **kwargs):
    """TRACE a live Page. Accepts the keyword arguments of Page.request."""
    return request("TRACE", url, **kwargs)

brimp.query

query(url, **kwargs)

QUERY a live Page. Accepts the keyword arguments of Page.request.

Source code in brimp/__init__.py
761
762
763
def query(url, **kwargs):
    """QUERY a live Page. Accepts the keyword arguments of Page.request."""
    return request("QUERY", url, **kwargs)

Sessions and pages

brimp.Session

Session(*, headers=None, base_url=None, params=None, timeout=30, proxy=None, proxies=None, proxy_auth=None, trust_env=True, auth=None, plugins=None, user_agent=None, languages=None, platform=None, profile=None, time_mode='system', time_origin=None, diagnostics=None, storage_path=None)

Own pages, shared cookies, request defaults and browser subsystem plugins.

Omit plugins for the browser defaults; an explicit list replaces that set. Pass plugins=[] for core-only execution.

Use as a context manager to close all owned pages. timeout accepts numeric seconds, or None/zero to disable the deadline. The default is 30 seconds; requests inherit it unless explicitly overridden. Each request method creates a new Page; use Page.request to reuse a page. base_url resolves relative request URLs. params supplies default query values; both attributes can be changed before subsequent requests. proxy or proxies sets default proxy routing; proxy_auth supplies credentials. trust_env controls environment proxies. proxy="" forces direct connections.

Source code in brimp/__init__.py
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
def __init__(
    self,
    *,
    headers=None,
    base_url=None,
    params=None,
    timeout=30,
    proxy=None,
    proxies=None,
    proxy_auth=None,
    trust_env=True,
    auth=None,
    plugins=None,
    user_agent=None,
    languages=None,
    platform=None,
    profile=None,
    time_mode="system",
    time_origin=None,
    diagnostics=None,
    storage_path=None,
):
    if isinstance(profile, Fingerprint):
        profile = {"values": {"network": {"fingerprint": profile}}}
    _validate_base_url(base_url)
    self.base_url = base_url
    self.params = {} if params is None else params
    pairs = _headers(headers)
    if auth is not None:
        pairs.append(
            (
                "Authorization",
                "Basic " + base64.b64encode(f"{auth[0]}:{auth[1]}".encode()).decode(),
            )
        )
    self._default_headers = tuple(pairs)
    self._plugin_token = object()
    self._plugin_disposers = []
    self._routes = set()
    bound = []
    try:
        for plugin in _browser_plugins() if plugins is None else plugins:
            plugin, dispose = plugin._bind()
            bound.append(plugin)
            if dispose:
                self._plugin_disposers.append(dispose)
        self._inner = _Session(
            pairs,
            _normalize_timeout(timeout),
            [plugin._descriptor(self._plugin_token) for plugin in bound],
            _json.dumps(dict(userAgent=user_agent, languages=languages, platform=platform)),
            _json.dumps(profile, allow_nan=False, default=_profile_json),
            _json.dumps(dict(mode=time_mode, epochMs=time_origin), allow_nan=False),
            _json.dumps(diagnostics, allow_nan=False),
            None if storage_path is None else str(storage_path),
            _json.dumps(_proxy_options(proxy, proxies, proxy_auth, trust_env)),
        )
    except BaseException:
        self._dispose_plugins()
        raise

base_url instance-attribute

base_url = base_url

cookies property

cookies

params instance-attribute

params = {} if params is None else params

clear_cookies

clear_cookies()
Source code in brimp/__init__.py
255
256
def clear_cookies(self):
    self._inner.clear_cookies()

close

close()
Source code in brimp/__init__.py
258
259
260
261
262
263
264
def close(self):
    _check_session(self._plugin_token)
    try:
        self._inner.close()
    finally:
        self._routes.clear()
        self._dispose_plugins()

delete

delete(url, **kwargs)
Source code in brimp/__init__.py
110
111
def delete(self, url, **kwargs):
    return self.request("DELETE", url, **kwargs)

get

get(url, **kwargs)
Source code in brimp/__init__.py
98
99
def get(self, url, **kwargs):
    return self.request("GET", url, **kwargs)

head

head(url, **kwargs)
Source code in brimp/__init__.py
113
114
def head(self, url, **kwargs):
    return self.request("HEAD", url, **kwargs)

new_page

new_page()

Create a blank page before attaching routes, listeners or init scripts.

Source code in brimp/__init__.py
218
219
220
221
def new_page(self):
    """Create a blank page before attaching routes, listeners or init scripts."""
    _check_session(self._plugin_token)
    return Page(self._inner.new_page(), self)

options

options(url, **kwargs)
Source code in brimp/__init__.py
116
117
def options(self, url, **kwargs):
    return self.request("OPTIONS", url, **kwargs)

patch

patch(url, **kwargs)
Source code in brimp/__init__.py
107
108
def patch(self, url, **kwargs):
    return self.request("PATCH", url, **kwargs)

post

post(url, **kwargs)
Source code in brimp/__init__.py
101
102
def post(self, url, **kwargs):
    return self.request("POST", url, **kwargs)

put

put(url, **kwargs)
Source code in brimp/__init__.py
104
105
def put(self, url, **kwargs):
    return self.request("PUT", url, **kwargs)

query

query(url, **kwargs)
Source code in brimp/__init__.py
122
123
def query(self, url, **kwargs):
    return self.request("QUERY", url, **kwargs)

request

request(method, url, **kwargs)

Navigate a new page. Keyword arguments are those of Page.request.

Source code in brimp/__init__.py
223
224
225
226
227
228
229
230
def request(self, method, url, **kwargs):
    """Navigate a new page. Keyword arguments are those of Page.request."""
    page = self.new_page()
    try:
        return page.request(method, url, **kwargs)
    except BaseException:
        page.close()
        raise

route

route(pattern, handler, *, stage='request')

Register a synchronous route on all existing and future pages.

Matching page routes take precedence. Returns a removal function.

Source code in brimp/__init__.py
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
def route(self, pattern, handler, *, stage="request"):
    """Register a synchronous route on all existing and future pages.

    Matching page routes take precedence. Returns a removal function.
    """
    _check_session(self._plugin_token)
    callback = _callback(self._plugin_token, lambda inner: handler(Route(inner)))
    registration = self._inner.route(pattern, stage, callback)
    self._routes.add(registration)

    def remove():
        registration.remove()
        self._routes.discard(registration)

    return remove
set_cookie(url, name, value)
Source code in brimp/__init__.py
248
249
def set_cookie(self, url, name, value):
    self._inner.set_cookie(url, name, value)

trace

trace(url, **kwargs)
Source code in brimp/__init__.py
119
120
def trace(self, url, **kwargs):
    return self.request("TRACE", url, **kwargs)

brimp.Page

Page(inner, session)

An HTTP result and its live DOM and JavaScript environment.

Obtain pages from Session. Navigation replaces the realm and invalidates old handles, and a successful request replaces the HTTP metadata. text and content contain the original response; html() serializes the current DOM. HTTP properties require a response: new_page() and load_html() have none. Headers and response cookies are lists of pairs. elapsed is seconds. Closing a page cancels its work; the session also owns cleanup. Pages returned by module-level helpers own a private session and close it on page closure.

Source code in brimp/__init__.py
405
406
407
408
409
410
411
def __init__(self, inner, session):
    self._inner = inner
    self._session = session
    self._response = None
    self._session_cleanup = None
    self._subscriptions = set()
    self._routes = set()

content property

content

cookies property

cookies

downloaded_bytes property

downloaded_bytes

elapsed property

elapsed

encoding property writable

encoding

Encoding used by text; override it to change response decoding.

header_bytes property

header_bytes

headers property

headers

history property

history

http_version property

http_version

reason property

reason

request_info property

request_info

The original HTTP request record; request() navigates the page.

status_code property

status_code

text property

text

uploaded_bytes property

uploaded_bytes

url property

url

add_init_script

add_init_script(source)
Source code in brimp/__init__.py
644
645
def add_init_script(self, source):
    self._inner.add_init_script(source)

advance_time

advance_time(milliseconds, *, max_tasks=10000)

Advance logical milliseconds, processing tasks in chronological order.

Source code in brimp/__init__.py
373
374
375
def advance_time(self, milliseconds, *, max_tasks=10000):
    """Advance logical milliseconds, processing tasks in chronological order."""
    return _json.loads(self._inner.advance_time(milliseconds, max_tasks))

clear_cache

clear_cache()
Source code in brimp/__init__.py
479
480
def clear_cache(self):
    self._inner.clear_cache()

click

click(selector)
Source code in brimp/__init__.py
647
648
def click(self, selector):
    self._inner.click(selector)

close

close()
Source code in brimp/__init__.py
692
693
694
695
def close(self):
    self._inner.close()
    if self._session_cleanup is not None:
        self._session_cleanup()

configure_network

configure_network(*, offline=False, latency=0.0, bypass_cache=False, max_retained_bytes=32 * 1024 * 1024, max_retained_body_bytes=8 * 1024 * 1024, buffered_download_bytes_per_second=None)
Source code in brimp/__init__.py
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
def configure_network(
    self,
    *,
    offline=False,
    latency=0.0,
    bypass_cache=False,
    max_retained_bytes=32 * 1024 * 1024,
    max_retained_body_bytes=8 * 1024 * 1024,
    buffered_download_bytes_per_second=None,
):
    self._inner.configure_network(
        offline,
        latency,
        bypass_cache,
        max_retained_bytes,
        max_retained_body_bytes,
        buffered_download_bytes_per_second,
    )

delete

delete(url, **kwargs)
Source code in brimp/__init__.py
110
111
def delete(self, url, **kwargs):
    return self.request("DELETE", url, **kwargs)

drag_to

drag_to(source, destination)
Source code in brimp/__init__.py
668
669
def drag_to(self, source, destination):
    self._inner.drag_to(source, destination)

evaluate

evaluate(source)

Evaluate browser JavaScript, await Promises, and copy rich bridge values.

Source code in brimp/__init__.py
630
631
632
def evaluate(self, source):
    """Evaluate browser JavaScript, await Promises, and copy rich bridge values."""
    return _decode(_json.loads(self._inner.evaluate(source)))

evaluate_handle

evaluate_handle(source)
Source code in brimp/__init__.py
634
635
def evaluate_handle(self, source):
    return JSHandle(self._inner.evaluate_handle(source))

extract

extract(*, content_selector=None, remove_images=False, language=None, debug=False)
Source code in brimp/__init__.py
674
675
676
677
678
679
680
681
682
683
684
685
686
def extract(self, *, content_selector=None, remove_images=False, language=None, debug=False):
    return _json.loads(
        self._inner.extract(
            _json.dumps(
                {
                    "contentSelector": content_selector,
                    "removeImages": remove_images,
                    "language": language,
                    "debug": debug,
                }
            )
        )
    )

fill

fill(selector, text)
Source code in brimp/__init__.py
662
663
def fill(self, selector, text):
    self._inner.fill(selector, text)

focus

focus(selector)
Source code in brimp/__init__.py
656
657
def focus(self, selector):
    self._inner.focus(selector)

get

get(url, **kwargs)
Source code in brimp/__init__.py
98
99
def get(self, url, **kwargs):
    return self.request("GET", url, **kwargs)

head

head(url, **kwargs)
Source code in brimp/__init__.py
113
114
def head(self, url, **kwargs):
    return self.request("HEAD", url, **kwargs)

hover

hover(selector)
Source code in brimp/__init__.py
650
651
def hover(self, selector):
    self._inner.hover(selector)

html

html()

Serialize the current DOM, including page-script and host edits.

Source code in brimp/__init__.py
688
689
690
def html(self):
    """Serialize the current DOM, including page-script and host edits."""
    return self._inner.html()

json

json()

Decode the original HTTP response body as JSON.

Source code in brimp/__init__.py
342
343
344
345
346
347
def json(self):
    """Decode the original HTTP response body as JSON."""
    try:
        return self._http_response().json()
    except _json.JSONDecodeError as error:
        raise JSONDecodeError(error.msg, error.doc, error.pos, response=self) from error

load_html

load_html(html, url='about:blank')

Load HTML at url without running its page scripts.

The URL becomes the browsing-context URL before parsing, so relative URLs, document.URL and location.href use it. Subresources are not fetched. Init scripts still run.

Source code in brimp/__init__.py
441
442
443
444
445
446
447
448
449
450
def load_html(self, html, url="about:blank"):
    """Load HTML at *url* without running its page scripts.

    The URL becomes the browsing-context URL before parsing, so relative
    URLs, document.URL and location.href use it. Subresources are not
    fetched. Init scripts still run.
    """
    result = self._inner.load_html(html, url)
    self._response = None
    return result

on

on(event, handler)

Subscribe a synchronous event handler; return an unsubscribe function.

Source code in brimp/__init__.py
413
414
415
416
417
418
419
420
421
422
423
def on(self, event, handler):
    """Subscribe a synchronous event handler; return an unsubscribe function."""
    callback = _callback(self._session._plugin_token, lambda wire: handler(_event_record(wire)))
    subscription = self._inner.on(event, callback)
    self._subscriptions.add(subscription)

    def unsubscribe():
        subscription.unsubscribe()
        self._subscriptions.discard(subscription)

    return unsubscribe

options

options(url, **kwargs)
Source code in brimp/__init__.py
116
117
def options(self, url, **kwargs):
    return self.request("OPTIONS", url, **kwargs)

patch

patch(url, **kwargs)
Source code in brimp/__init__.py
107
108
def patch(self, url, **kwargs):
    return self.request("PATCH", url, **kwargs)

peek_diagnostics

peek_diagnostics()

Inspect retained records, coverage and loss without consuming them.

Source code in brimp/__init__.py
393
394
395
def peek_diagnostics(self):
    """Inspect retained records, coverage and loss without consuming them."""
    return _snake_record(_json.loads(self._inner.peek_diagnostics()))

post

post(url, **kwargs)
Source code in brimp/__init__.py
101
102
def post(self, url, **kwargs):
    return self.request("POST", url, **kwargs)

press

press(selector, key, *, modifiers=0)
Source code in brimp/__init__.py
665
666
def press(self, selector, key, *, modifiers=0):
    self._inner.press(selector, key, modifiers)

profile_contract

profile_contract()

Describe installed profile interfaces, preserving their original field names.

Source code in brimp/__init__.py
381
382
383
def profile_contract(self):
    """Describe installed profile interfaces, preserving their original field names."""
    return _json.loads(self._inner.profile_contract())

profile_report

profile_report()

Return defaulted paths and capture metadata without renaming profile keys.

Source code in brimp/__init__.py
385
386
387
def profile_report(self):
    """Return defaulted paths and capture metadata without renaming profile keys."""
    return _json.loads(self._inner.profile_report())

put

put(url, **kwargs)
Source code in brimp/__init__.py
104
105
def put(self, url, **kwargs):
    return self.request("PUT", url, **kwargs)

query

query(url, **kwargs)
Source code in brimp/__init__.py
122
123
def query(self, url, **kwargs):
    return self.request("QUERY", url, **kwargs)

query_selector

query_selector(selector)
Source code in brimp/__init__.py
637
638
639
def query_selector(self, selector):
    inner = self._inner.query_selector(selector)
    return ElementHandle(inner) if inner is not None else None

query_selector_all

query_selector_all(selector)
Source code in brimp/__init__.py
641
642
def query_selector_all(self, selector):
    return [ElementHandle(inner) for inner in self._inner.query_selector_all(selector)]

raise_for_status

raise_for_status()

Raise HTTPError for a 4xx/5xx response; otherwise return None.

HTTP statuses do not raise automatically during navigation. A page without an HTTP response raises InvalidInput.

Source code in brimp/__init__.py
349
350
351
352
353
354
355
356
357
358
def raise_for_status(self):
    """Raise HTTPError for a 4xx/5xx response; otherwise return None.

    HTTP statuses do not raise automatically during navigation. A page
    without an HTTP response raises InvalidInput.
    """
    if 400 <= self.status_code < 600:
        raise HTTPError(
            f"HTTP {self.status_code} {self.reason} for url: {self.url}", response=self
        )

request

request(method, url, *, params=None, quote='', headers=None, body=None, data=None, content=None, json=None, timeout=_TIMEOUT_UNSET, allow_redirects=True, max_redirects=20, auth=None, proxy=None, proxies=None, proxy_auth=None, trust_env=None)

Navigate this page and return it with a new response snapshot.

json encodes a JSON value; content sends raw strings/bytes; data sends strings/bytes unchanged or URL-encodes a form mapping/sequence of pairs. Non-None json takes precedence over content, then data. body accepts raw strings/bytes and cannot be combined with those arguments. Explicit Content-Type headers override defaults. File/multipart uploads are unsupported. timeout accepts numeric seconds as one operation budget. None/zero disables it; omission inherits the session default. This is one navigation deadline, including JavaScript, not separate connection/read timers. HTTP error statuses remain accessible. params merges query values with session defaults. Relative URLs use the session's base_url. quote names extra characters to percent-encode; quote=False disables automatic URL quoting. Proxy overrides apply to this navigation and its redirects; subresources use session settings and routes. proxy="" forces a direct connection.

Source code in brimp/__init__.py
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
def request(
    self,
    method,
    url,
    *,
    params=None,
    quote="",
    headers=None,
    body=None,
    data=None,
    content=None,
    json=None,
    timeout=_TIMEOUT_UNSET,
    allow_redirects=True,
    max_redirects=20,
    auth=None,
    proxy=None,
    proxies=None,
    proxy_auth=None,
    trust_env=None,
):
    """Navigate this page and return it with a new response snapshot.

    json encodes a JSON value; content sends raw strings/bytes; data sends
    strings/bytes unchanged or URL-encodes a form mapping/sequence of pairs.
    Non-None json takes precedence over content, then data. body accepts raw
    strings/bytes and cannot be combined with those arguments. Explicit
    Content-Type headers override defaults. File/multipart uploads are unsupported.
    timeout accepts numeric seconds as one operation budget. None/zero disables it;
    omission inherits the session default. This is one navigation deadline, including JavaScript, not
    separate connection/read timers. HTTP error statuses remain accessible.
    params merges query values with session defaults. Relative URLs use the
    session's base_url. quote names extra characters to percent-encode;
    quote=False disables automatic URL quoting.
    Proxy overrides apply to this navigation and its redirects; subresources
    use session settings and routes. proxy="" forces a direct connection.
    """
    url = self._request_url(url, params, quote)
    pairs = _headers(headers)
    body = _encode_body(
        body=body,
        data=data,
        content=content,
        json=json,
        headers=pairs,
        default_headers=self._session._default_headers,
    )
    if auth is not None:
        pairs = [(k, v) for k, v in pairs if k.lower() != "authorization"]
        pairs.append(
            (
                "Authorization",
                "Basic " + base64.b64encode(f"{auth[0]}:{auth[1]}".encode()).decode(),
            )
        )
    result = self._inner.request(
        method,
        url,
        pairs,
        body,
        _normalize_timeout(timeout),
        allow_redirects,
        max_redirects,
        _json.dumps(_proxy_options(proxy, proxies, proxy_auth, trust_env)),
    )
    self._response = _Response(result)
    return self

response_body

response_body(request_id)
Source code in brimp/__init__.py
482
483
def response_body(self, request_id):
    return self._inner.response_body(request_id)

route

route(pattern, handler, *, stage='request')

Intercept a glob pattern at request, response or auth stage.

Last matching route wins. Complete the route exactly once. The callback must be synchronous and cannot reenter this page. Returns a remover.

Source code in brimp/__init__.py
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
def route(self, pattern, handler, *, stage="request"):
    """Intercept a glob pattern at request, response or auth stage.

    Last matching route wins. Complete the route exactly once. The callback
    must be synchronous and cannot reenter this page. Returns a remover.
    """
    callback = _callback(self._session._plugin_token, lambda inner: handler(Route(inner)))
    registration = self._inner.route(pattern, stage, callback)
    self._routes.add(registration)

    def remove():
        registration.remove()
        self._routes.discard(registration)

    return remove

run_pending_tasks

run_pending_tasks(*, max_tasks=10000)

Drain currently due tasks without advancing logical time.

Source code in brimp/__init__.py
377
378
379
def run_pending_tasks(self, *, max_tasks=10000):
    """Drain currently due tasks without advancing logical time."""
    return _json.loads(self._inner.run_pending_tasks(max_tasks))

set_extra_headers

set_extra_headers(headers)
Source code in brimp/__init__.py
476
477
def set_extra_headers(self, headers):
    self._inner.set_extra_headers(_headers(headers))

set_identity

set_identity(*, user_agent=None, languages=None, platform=None)
Source code in brimp/__init__.py
452
453
454
455
def set_identity(self, *, user_agent=None, languages=None, platform=None):
    self._inner.set_identity(
        _json.dumps(dict(userAgent=user_agent, languages=languages, platform=platform))
    )

set_input_files

set_input_files(selector, files)
Source code in brimp/__init__.py
671
672
def set_input_files(self, selector, files):
    self._inner.set_input_files(selector, _files(files))

stream

stream(method, url, *, params=None, quote='', headers=None, body=None, data=None, content=None, json=None, timeout=_TIMEOUT_UNSET, allow_redirects=True, max_redirects=20, auth=None, proxy=None, proxies=None, proxy_auth=None, trust_env=None)

Stream response bytes without replacing the DOM. Close abandoned streams.

Body arguments follow request(): json, content, data or standalone body. Uploads are buffered; file-like, iterable and multipart uploads are unsupported.

Source code in brimp/__init__.py
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
def stream(
    self,
    method,
    url,
    *,
    params=None,
    quote="",
    headers=None,
    body=None,
    data=None,
    content=None,
    json=None,
    timeout=_TIMEOUT_UNSET,
    allow_redirects=True,
    max_redirects=20,
    auth=None,
    proxy=None,
    proxies=None,
    proxy_auth=None,
    trust_env=None,
):
    """Stream response bytes without replacing the DOM. Close abandoned streams.

    Body arguments follow request(): json, content, data or standalone body.
    Uploads are buffered; file-like, iterable and multipart uploads are unsupported.
    """
    url = self._request_url(url, params, quote)
    pairs = _headers(headers)
    body = _encode_body(
        body=body,
        data=data,
        content=content,
        json=json,
        headers=pairs,
        default_headers=self._session._default_headers,
    )
    if auth is not None:
        pairs.append(
            (
                "Authorization",
                "Basic " + base64.b64encode(f"{auth[0]}:{auth[1]}".encode()).decode(),
            )
        )
    return StreamingResponse(
        self._inner.stream(
            method,
            url,
            pairs,
            body,
            _normalize_timeout(timeout),
            allow_redirects,
            max_redirects,
            _json.dumps(_proxy_options(proxy, proxies, proxy_auth, trust_env)),
        ),
        self,
    )

summarize_diagnostics

summarize_diagnostics()

Group retained observations by layer/path/kind and reflection target.

Does not consume records. Counts cover the retained, filtered window; missing records do not establish that an API was never accessed.

Source code in brimp/__init__.py
397
398
399
400
401
402
403
def summarize_diagnostics(self):
    """Group retained observations by layer/path/kind and reflection target.

    Does not consume records. Counts cover the retained, filtered window;
    missing records do not establish that an API was never accessed.
    """
    return _snake_record(_json.loads(self._inner.summarize_diagnostics()))

take_diagnostics

take_diagnostics()

Consume bounded records; JSONL output is unaffected.

Source code in brimp/__init__.py
389
390
391
def take_diagnostics(self):
    """Consume bounded records; JSONL output is unaffected."""
    return _snake_record(_json.loads(self._inner.take_diagnostics()))

tap

tap(selector)
Source code in brimp/__init__.py
653
654
def tap(self, selector):
    self._inner.tap(selector)

trace

trace(url, **kwargs)
Source code in brimp/__init__.py
119
120
def trace(self, url, **kwargs):
    return self.request("TRACE", url, **kwargs)

type_text

type_text(selector, text)
Source code in brimp/__init__.py
659
660
def type_text(self, selector, text):
    self._inner.type_text(selector, text)

brimp.JSHandle

JSHandle(inner)

Rooted JavaScript value. Dispose explicitly or use a context manager.

Navigation invalidates handles from the previous realm.

Source code in brimp/__init__.py
812
813
def __init__(self, inner):
    self._inner = inner

call

call(function, *args)
Source code in brimp/__init__.py
833
834
835
836
def call(self, function, *args):
    return self._command(
        op="call", source=function, args=[_encode(arg) for arg in args], handle=True
    )

delete_property

delete_property(name)
Source code in brimp/__init__.py
849
850
def delete_property(self, name):
    return self._command(op="delete", name=name)

dispose

dispose()
Source code in brimp/__init__.py
855
856
def dispose(self):
    self._inner.dispose()

invoke

invoke(*args, this=undefined)
Source code in brimp/__init__.py
838
839
840
841
def invoke(self, *args, this=undefined):
    return self._command(
        op="invoke", args=[_encode(arg) for arg in args], receiver=_encode(this), handle=True
    )

json_value

json_value()
Source code in brimp/__init__.py
830
831
def json_value(self):
    return _json.loads(self._command(op="json"))

property

property(name)
Source code in brimp/__init__.py
843
844
def property(self, name):
    return self._command(op="property", name=name, handle=True)

property_names

property_names()
Source code in brimp/__init__.py
852
853
def property_names(self):
    return self._command(op="names")

set_property

set_property(name, value)
Source code in brimp/__init__.py
846
847
def set_property(self, name, value):
    return self._command(op="set", name=name, args=[_encode(value)])

value

value()
Source code in brimp/__init__.py
827
828
def value(self):
    return self._command(op="value")

brimp.ElementHandle

ElementHandle(inner)

Rooted DOM node with query, edit and input methods. Detachment keeps identity.

Source code in brimp/__init__.py
812
813
def __init__(self, inner):
    self._inner = inner

call

call(function, *args)
Source code in brimp/__init__.py
833
834
835
836
def call(self, function, *args):
    return self._command(
        op="call", source=function, args=[_encode(arg) for arg in args], handle=True
    )

click

click()
Source code in brimp/__init__.py
885
886
def click(self):
    self._inner.click()

delete_property

delete_property(name)
Source code in brimp/__init__.py
849
850
def delete_property(self, name):
    return self._command(op="delete", name=name)

dispose

dispose()
Source code in brimp/__init__.py
855
856
def dispose(self):
    self._inner.dispose()

focus

focus()
Source code in brimp/__init__.py
882
883
def focus(self):
    self._inner.focus()

get_attribute

get_attribute(name)
Source code in brimp/__init__.py
895
896
def get_attribute(self, name):
    return self._value("(node, name) => node.getAttribute(name)", name)

html

html()
Source code in brimp/__init__.py
906
907
def html(self):
    return self._value("node => node.outerHTML")

invoke

invoke(*args, this=undefined)
Source code in brimp/__init__.py
838
839
840
841
def invoke(self, *args, this=undefined):
    return self._command(
        op="invoke", args=[_encode(arg) for arg in args], receiver=_encode(this), handle=True
    )

json_value

json_value()
Source code in brimp/__init__.py
830
831
def json_value(self):
    return _json.loads(self._command(op="json"))

property

property(name)
Source code in brimp/__init__.py
843
844
def property(self, name):
    return self._command(op="property", name=name, handle=True)

property_names

property_names()
Source code in brimp/__init__.py
852
853
def property_names(self):
    return self._command(op="names")

query_selector

query_selector(selector)
Source code in brimp/__init__.py
915
916
917
def query_selector(self, selector):
    inner = self._inner.query_selector(selector)
    return ElementHandle(inner) if inner is not None else None

query_selector_all

query_selector_all(selector)
Source code in brimp/__init__.py
919
920
def query_selector_all(self, selector):
    return [ElementHandle(inner) for inner in self._inner.query_selector_all(selector)]

remove

remove()
Source code in brimp/__init__.py
912
913
def remove(self):
    self._value("node => { node.remove(); return null; }")

set_attribute

set_attribute(name, value)
Source code in brimp/__init__.py
898
899
900
901
def set_attribute(self, name, value):
    self._value(
        "(node, name, value) => { node.setAttribute(name, value); return null; }", name, value
    )

set_input_files

set_input_files(files)
Source code in brimp/__init__.py
888
889
def set_input_files(self, files):
    self._inner.set_input_files(_files(files))

set_property

set_property(name, value)
Source code in brimp/__init__.py
846
847
def set_property(self, name, value):
    return self._command(op="set", name=name, args=[_encode(value)])

set_text_content

set_text_content(text)
Source code in brimp/__init__.py
909
910
def set_text_content(self, text):
    self._value("(node, text) => { node.textContent = text; return null; }", text)

text_content

text_content()
Source code in brimp/__init__.py
903
904
def text_content(self):
    return self._value("node => node.textContent")

value

value()
Source code in brimp/__init__.py
827
828
def value(self):
    return self._command(op="value")

brimp.Route

Route(inner)

One intercepted request. Choose exactly one completion method.

Response-stage interception is buffered, with a 32 MiB limit.

Source code in brimp/__init__.py
934
935
936
937
938
def __init__(self, inner):
    self._inner = inner
    self.__dict__.update(_snake_record(_json.loads(inner.info_json())))
    if self.request["body"] is not None:
        self.request["body"] = bytes(self.request["body"])

auth_challenge instance-attribute

auth_challenge: str | None

pending property

pending

request instance-attribute

request: dict

response instance-attribute

response: dict | None

stage instance-attribute

stage: str

authenticate

authenticate(username, password)
Source code in brimp/__init__.py
987
988
def authenticate(self, username, password):
    self._inner.authenticate(username, password)

body

body()
Source code in brimp/__init__.py
944
945
def body(self):
    return self._inner.body()

continue_request

continue_request(*, url=None, method=None, headers=None, body=None, status=None, proxy=None, proxy_auth=None)

Continue once, optionally changing request fields or its proxy.

proxy=None inherits; proxy="" connects directly. Proxy overrides are request-stage only. Supply proxy_auth when changing authenticated proxies.

Source code in brimp/__init__.py
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
def continue_request(
    self,
    *,
    url=None,
    method=None,
    headers=None,
    body=None,
    status=None,
    proxy=None,
    proxy_auth=None,
):
    """Continue once, optionally changing request fields or its proxy.

    proxy=None inherits; proxy="" connects directly. Proxy overrides are
    request-stage only. Supply proxy_auth when changing authenticated proxies.
    """
    overrides = {
        key: value
        for key, value in {
            "url": url,
            "method": method,
            "headers": None if headers is None else _headers(headers),
            "body": None
            if body is None
            else list(body.encode() if isinstance(body, str) else body),
            "status": status,
        }.items()
        if value is not None
    }
    overrides.update(_proxy_options(proxy=proxy, proxy_auth=proxy_auth))
    self._inner.continue_request(_json.dumps(overrides))

fail

fail(message='request aborted by route')
Source code in brimp/__init__.py
984
985
def fail(self, message="request aborted by route"):
    self._inner.fail(message)

fulfill

fulfill(*, status=200, headers=None, body=b'')
Source code in brimp/__init__.py
979
980
981
982
def fulfill(self, *, status=200, headers=None, body=b""):
    self._inner.fulfill(
        status, _headers(headers), body.encode() if isinstance(body, str) else body
    )

brimp.StreamingResponse

StreamingResponse(inner, page)

A bounded chunk iterator. Close it when abandoning a response body.

Source code in brimp/__init__.py
 998
 999
1000
1001
1002
1003
1004
1005
def __init__(self, inner, page):
    self._inner, self._page = inner, page
    metadata = _json.loads(inner.metadata_json())
    self.status_code, self.url, self.headers = (
        metadata["status"],
        metadata["url"],
        metadata["headers"],
    )

headers instance-attribute

headers: list[tuple[str, str]]

status_code instance-attribute

status_code: int

url instance-attribute

url: str

close

close()
Source code in brimp/__init__.py
1016
1017
def close(self):
    self._inner.cancel()

Async sessions and pages

Use async with brimp.AsyncSession(...) and await requests, page operations and handle methods. Buffered HTTP properties, json() and raise_for_status() stay synchronous. Page callback registration stays synchronous; session routes use await session.route(...). Handlers and removal functions remain synchronous. Async streaming and coroutine callbacks are not yet supported.

brimp.AsyncSession

AsyncSession(*, max_clients=10, **kwargs)

An asyncio session with at most max_clients concurrent native operations.

Accepts Session's keyword options. Native initialization is lazy; use async with or await close() to release resources. A session belongs to the event loop of its first use. Separate pages run concurrently; calls on one page are serialized. Completed requests do not occupy concurrency slots. Plugin and route callbacks remain synchronous in this API.

Source code in brimp/_async.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
def __init__(self, *, max_clients=10, **kwargs):
    if isinstance(max_clients, bool) or not isinstance(max_clients, int) or max_clients < 1:
        raise ValueError("max_clients must be a positive integer")
    self.max_clients = max_clients
    self.base_url = kwargs.pop("base_url", None)
    self.params = kwargs.pop("params", None)
    if self.params is None:
        self.params = {}
    self._options = kwargs
    self._loop = None
    self._executor = ThreadPoolExecutor(
        max_workers=max_clients, thread_name_prefix="brimp-async"
    )
    self._slots = asyncio.Semaphore(max_clients)
    self._initializing = None
    self._sync = None
    self._pending = {}
    self._closed = False
    self._closing = None

base_url instance-attribute

base_url = kwargs.pop('base_url', None)

cookies property

cookies

Snapshot of the shared cookie jar; empty before first use.

max_clients instance-attribute

max_clients = max_clients

params instance-attribute

params = kwargs.pop('params', None)

clear_cookies async

clear_cookies()
Source code in brimp/_async.py
162
163
async def clear_cookies(self):
    await self._run(lambda: self._sync.clear_cookies())

close async

close()

Cancel pending work, close all pages and drain native worker threads.

Source code in brimp/_async.py
171
172
173
174
175
176
177
178
179
180
181
async def close(self):
    """Cancel pending work, close all pages and drain native worker threads."""
    self._check_loop()
    if self._closing is None:
        self._closed = True
        self._closing = asyncio.create_task(self._shutdown())
    try:
        await asyncio.shield(self._closing)
    except asyncio.CancelledError:
        await _drain(self._closing)
        raise

delete async

delete(url, **kwargs)
Source code in brimp/_async.py
41
42
async def delete(self, url, **kwargs):
    return await self.request("DELETE", url, **kwargs)

get async

get(url, **kwargs)
Source code in brimp/_async.py
26
27
async def get(self, url, **kwargs):
    return await self.request("GET", url, **kwargs)

head async

head(url, **kwargs)
Source code in brimp/_async.py
29
30
async def head(self, url, **kwargs):
    return await self.request("HEAD", url, **kwargs)

new_page async

new_page()

Create a blank AsyncPage. The session owns its lifetime.

Source code in brimp/_async.py
140
141
142
143
async def new_page(self):
    """Create a blank AsyncPage. The session owns its lifetime."""
    page = await self._run(lambda: self._sync.new_page(), cleanup=lambda page: page.close())
    return AsyncPage(page, self)

options async

options(url, **kwargs)
Source code in brimp/_async.py
44
45
async def options(self, url, **kwargs):
    return await self.request("OPTIONS", url, **kwargs)

patch async

patch(url, **kwargs)
Source code in brimp/_async.py
38
39
async def patch(self, url, **kwargs):
    return await self.request("PATCH", url, **kwargs)

post async

post(url, **kwargs)
Source code in brimp/_async.py
32
33
async def post(self, url, **kwargs):
    return await self.request("POST", url, **kwargs)

put async

put(url, **kwargs)
Source code in brimp/_async.py
35
36
async def put(self, url, **kwargs):
    return await self.request("PUT", url, **kwargs)

query async

query(url, **kwargs)
Source code in brimp/_async.py
50
51
async def query(self, url, **kwargs):
    return await self.request("QUERY", url, **kwargs)

request async

request(method, url, **kwargs)

Navigate a new AsyncPage; accepts Page.request keyword arguments.

Source code in brimp/_async.py
145
146
147
148
149
150
151
152
async def request(self, method, url, **kwargs):
    """Navigate a new AsyncPage; accepts Page.request keyword arguments."""
    page = await self.new_page()
    try:
        return await page.request(method, url, **kwargs)
    except BaseException:
        await page.close()
        raise

route async

route(pattern, handler, *, stage='request')

Register a synchronous route for existing and future pages.

Source code in brimp/_async.py
154
155
156
157
async def route(self, pattern, handler, *, stage="request"):
    """Register a synchronous route for existing and future pages."""
    await self._ready()
    return self._sync.route(pattern, handler, stage=stage)
set_cookie(url, name, value)
Source code in brimp/_async.py
159
160
async def set_cookie(self, url, name, value):
    await self._run(lambda: self._sync.set_cookie(url, name, value))

trace async

trace(url, **kwargs)
Source code in brimp/_async.py
47
48
async def trace(self, url, **kwargs):
    return await self.request("TRACE", url, **kwargs)

brimp.AsyncPage

AsyncPage(page, session)

A live async page with synchronous buffered HTTP properties and json().

Await navigation, JavaScript, DOM and handle operations. Cancellation stops the active native call; queued calls on this page wait for its cleanup. Use async with an existing page, or await close().

Source code in brimp/_async.py
218
219
220
221
222
def __init__(self, page, session):
    self._page, self._session = page, session
    self._lock = asyncio.Lock()
    self._closed = False
    self._closing = None

content property

content

cookies property

cookies

downloaded_bytes property

downloaded_bytes

elapsed property

elapsed

encoding property writable

encoding

Encoding used by text; override it to change response decoding.

header_bytes property

header_bytes

headers property

headers

history property

history

http_version property

http_version

reason property

reason

request_info property

request_info

The original HTTP request record; request() navigates the page.

status_code property

status_code

text property

text

uploaded_bytes property

uploaded_bytes

url property

url

add_init_script async

add_init_script(source)
Source code in brimp/_async.py
352
353
async def add_init_script(self, source):
    return await self._call(self._page.add_init_script, source)

advance_time async

advance_time(milliseconds, *, max_tasks=10000)
Source code in brimp/_async.py
282
283
async def advance_time(self, milliseconds, *, max_tasks=10000):
    return await self._call(self._page.advance_time, milliseconds, max_tasks=max_tasks)

clear_cache async

clear_cache()
Source code in brimp/_async.py
334
335
async def clear_cache(self):
    return await self._call(self._page.clear_cache)

click async

click(selector)
Source code in brimp/_async.py
355
356
async def click(self, selector):
    return await self._call(self._page.click, selector)

close async

close()

Close this page, interrupting its work without closing sibling pages.

Source code in brimp/_async.py
261
262
263
264
265
266
267
268
269
270
271
async def close(self):
    """Close this page, interrupting its work without closing sibling pages."""
    loop = self._session._check_loop()
    if self._closing is None:
        self._closed = True
        self._closing = loop.run_in_executor(None, self._page.close)
    try:
        await asyncio.shield(self._closing)
    except asyncio.CancelledError:
        await _drain(self._closing)
        raise

configure_network async

configure_network(*, offline=False, latency=0.0, bypass_cache=False, max_retained_bytes=32 * 1024 * 1024, max_retained_body_bytes=8 * 1024 * 1024, buffered_download_bytes_per_second=None)
Source code in brimp/_async.py
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
async def configure_network(
    self,
    *,
    offline=False,
    latency=0.0,
    bypass_cache=False,
    max_retained_bytes=32 * 1024 * 1024,
    max_retained_body_bytes=8 * 1024 * 1024,
    buffered_download_bytes_per_second=None,
):
    return await self._call(
        self._page.configure_network,
        offline=offline,
        latency=latency,
        bypass_cache=bypass_cache,
        max_retained_bytes=max_retained_bytes,
        max_retained_body_bytes=max_retained_body_bytes,
        buffered_download_bytes_per_second=buffered_download_bytes_per_second,
    )

delete async

delete(url, **kwargs)
Source code in brimp/_async.py
41
42
async def delete(self, url, **kwargs):
    return await self.request("DELETE", url, **kwargs)

drag_to async

drag_to(source, destination)
Source code in brimp/_async.py
376
377
async def drag_to(self, source, destination):
    return await self._call(self._page.drag_to, source, destination)

evaluate async

evaluate(source)
Source code in brimp/_async.py
340
341
async def evaluate(self, source):
    return await self._call(self._page.evaluate, source)

evaluate_handle async

evaluate_handle(source)
Source code in brimp/_async.py
343
344
async def evaluate_handle(self, source):
    return await self._call(self._page.evaluate_handle, source)

extract async

extract(*, content_selector=None, remove_images=False, language=None, debug=False)
Source code in brimp/_async.py
382
383
384
385
386
387
388
389
390
391
async def extract(
    self, *, content_selector=None, remove_images=False, language=None, debug=False
):
    return await self._call(
        self._page.extract,
        content_selector=content_selector,
        remove_images=remove_images,
        language=language,
        debug=debug,
    )

fill async

fill(selector, text)
Source code in brimp/_async.py
370
371
async def fill(self, selector, text):
    return await self._call(self._page.fill, selector, text)

focus async

focus(selector)
Source code in brimp/_async.py
364
365
async def focus(self, selector):
    return await self._call(self._page.focus, selector)

get async

get(url, **kwargs)
Source code in brimp/_async.py
26
27
async def get(self, url, **kwargs):
    return await self.request("GET", url, **kwargs)

head async

head(url, **kwargs)
Source code in brimp/_async.py
29
30
async def head(self, url, **kwargs):
    return await self.request("HEAD", url, **kwargs)

hover async

hover(selector)
Source code in brimp/_async.py
358
359
async def hover(self, selector):
    return await self._call(self._page.hover, selector)

html async

html()
Source code in brimp/_async.py
393
394
async def html(self):
    return await self._call(self._page.html)

json

json()

Decode the original HTTP response body as JSON.

Source code in brimp/__init__.py
342
343
344
345
346
347
def json(self):
    """Decode the original HTTP response body as JSON."""
    try:
        return self._http_response().json()
    except _json.JSONDecodeError as error:
        raise JSONDecodeError(error.msg, error.doc, error.pos, response=self) from error

load_html async

load_html(html, url='about:blank')
Source code in brimp/_async.py
303
304
async def load_html(self, html, url="about:blank"):
    return await self._call(self._page.load_html, html, url)

on

on(event, handler)

Register a synchronous event callback; returns an unsubscribe function.

Source code in brimp/_async.py
251
252
253
254
def on(self, event, handler):
    """Register a synchronous event callback; returns an unsubscribe function."""
    self._session._check_loop()
    return self._page.on(event, handler)

options async

options(url, **kwargs)
Source code in brimp/_async.py
44
45
async def options(self, url, **kwargs):
    return await self.request("OPTIONS", url, **kwargs)

patch async

patch(url, **kwargs)
Source code in brimp/_async.py
38
39
async def patch(self, url, **kwargs):
    return await self.request("PATCH", url, **kwargs)

peek_diagnostics async

peek_diagnostics()
Source code in brimp/_async.py
297
298
async def peek_diagnostics(self):
    return await self._call(self._page.peek_diagnostics)

post async

post(url, **kwargs)
Source code in brimp/_async.py
32
33
async def post(self, url, **kwargs):
    return await self.request("POST", url, **kwargs)

press async

press(selector, key, *, modifiers=0)
Source code in brimp/_async.py
373
374
async def press(self, selector, key, *, modifiers=0):
    return await self._call(self._page.press, selector, key, modifiers=modifiers)

profile_contract async

profile_contract()
Source code in brimp/_async.py
288
289
async def profile_contract(self):
    return await self._call(self._page.profile_contract)

profile_report async

profile_report()
Source code in brimp/_async.py
291
292
async def profile_report(self):
    return await self._call(self._page.profile_report)

put async

put(url, **kwargs)
Source code in brimp/_async.py
35
36
async def put(self, url, **kwargs):
    return await self.request("PUT", url, **kwargs)

query async

query(url, **kwargs)
Source code in brimp/_async.py
50
51
async def query(self, url, **kwargs):
    return await self.request("QUERY", url, **kwargs)

query_selector async

query_selector(selector)
Source code in brimp/_async.py
346
347
async def query_selector(self, selector):
    return await self._call(self._page.query_selector, selector)

query_selector_all async

query_selector_all(selector)
Source code in brimp/_async.py
349
350
async def query_selector_all(self, selector):
    return await self._call(self._page.query_selector_all, selector)

raise_for_status

raise_for_status()

Raise HTTPError for a 4xx/5xx response; otherwise return None.

HTTP statuses do not raise automatically during navigation. A page without an HTTP response raises InvalidInput.

Source code in brimp/__init__.py
349
350
351
352
353
354
355
356
357
358
def raise_for_status(self):
    """Raise HTTPError for a 4xx/5xx response; otherwise return None.

    HTTP statuses do not raise automatically during navigation. A page
    without an HTTP response raises InvalidInput.
    """
    if 400 <= self.status_code < 600:
        raise HTTPError(
            f"HTTP {self.status_code} {self.reason} for url: {self.url}", response=self
        )

request async

request(method, url, **kwargs)

Navigate this page using the same options as Page.request.

Source code in brimp/_async.py
246
247
248
249
async def request(self, method, url, **kwargs):
    """Navigate this page using the same options as Page.request."""
    await self._call(self._page.request, method, url, **kwargs)
    return self

response_body async

response_body(request_id)
Source code in brimp/_async.py
337
338
async def response_body(self, request_id):
    return await self._call(self._page.response_body, request_id)

route

route(pattern, handler, *, stage='request')

Register a synchronous route callback; returns a removal function.

Source code in brimp/_async.py
256
257
258
259
def route(self, pattern, handler, *, stage="request"):
    """Register a synchronous route callback; returns a removal function."""
    self._session._check_loop()
    return self._page.route(pattern, handler, stage=stage)

run_pending_tasks async

run_pending_tasks(*, max_tasks=10000)
Source code in brimp/_async.py
285
286
async def run_pending_tasks(self, *, max_tasks=10000):
    return await self._call(self._page.run_pending_tasks, max_tasks=max_tasks)

set_extra_headers async

set_extra_headers(headers)
Source code in brimp/_async.py
331
332
async def set_extra_headers(self, headers):
    return await self._call(self._page.set_extra_headers, headers)

set_identity async

set_identity(*, user_agent=None, languages=None, platform=None)
Source code in brimp/_async.py
306
307
308
309
async def set_identity(self, *, user_agent=None, languages=None, platform=None):
    return await self._call(
        self._page.set_identity, user_agent=user_agent, languages=languages, platform=platform
    )

set_input_files async

set_input_files(selector, files)
Source code in brimp/_async.py
379
380
async def set_input_files(self, selector, files):
    return await self._call(self._page.set_input_files, selector, files)

summarize_diagnostics async

summarize_diagnostics()
Source code in brimp/_async.py
300
301
async def summarize_diagnostics(self):
    return await self._call(self._page.summarize_diagnostics)

take_diagnostics async

take_diagnostics()
Source code in brimp/_async.py
294
295
async def take_diagnostics(self):
    return await self._call(self._page.take_diagnostics)

tap async

tap(selector)
Source code in brimp/_async.py
361
362
async def tap(self, selector):
    return await self._call(self._page.tap, selector)

trace async

trace(url, **kwargs)
Source code in brimp/_async.py
47
48
async def trace(self, url, **kwargs):
    return await self.request("TRACE", url, **kwargs)

type_text async

type_text(selector, text)
Source code in brimp/_async.py
367
368
async def type_text(self, selector, text):
    return await self._call(self._page.type_text, selector, text)

brimp.AsyncJSHandle

AsyncJSHandle(handle, page)

An async rooted JavaScript value; await dispose() to release its root.

Source code in brimp/_async.py
400
401
def __init__(self, handle, page):
    self._handle, self._page = handle, page

call async

call(function, *args)
Source code in brimp/_async.py
415
416
async def call(self, function, *args):
    return await self._page._call(self._handle.call, function, *args)

delete_property async

delete_property(name)
Source code in brimp/_async.py
427
428
async def delete_property(self, name):
    return await self._page._call(self._handle.delete_property, name)

dispose async

dispose()
Source code in brimp/_async.py
433
434
async def dispose(self):
    return await self._page._call(self._handle.dispose)

invoke async

invoke(*args, this=undefined)
Source code in brimp/_async.py
418
419
async def invoke(self, *args, this=undefined):
    return await self._page._call(self._handle.invoke, *args, this=this)

json_value async

json_value()
Source code in brimp/_async.py
412
413
async def json_value(self):
    return await self._page._call(self._handle.json_value)

property async

property(name)
Source code in brimp/_async.py
421
422
async def property(self, name):
    return await self._page._call(self._handle.property, name)

property_names async

property_names()
Source code in brimp/_async.py
430
431
async def property_names(self):
    return await self._page._call(self._handle.property_names)

set_property async

set_property(name, value)
Source code in brimp/_async.py
424
425
async def set_property(self, name, value):
    return await self._page._call(self._handle.set_property, name, value)

value async

value()
Source code in brimp/_async.py
409
410
async def value(self):
    return await self._page._call(self._handle.value)

brimp.AsyncElementHandle

AsyncElementHandle(handle, page)

An async DOM element with query, edit and input operations.

Source code in brimp/_async.py
400
401
def __init__(self, handle, page):
    self._handle, self._page = handle, page

call async

call(function, *args)
Source code in brimp/_async.py
415
416
async def call(self, function, *args):
    return await self._page._call(self._handle.call, function, *args)

click async

click()
Source code in brimp/_async.py
443
444
async def click(self):
    return await self._page._call(self._handle.click)

delete_property async

delete_property(name)
Source code in brimp/_async.py
427
428
async def delete_property(self, name):
    return await self._page._call(self._handle.delete_property, name)

dispose async

dispose()
Source code in brimp/_async.py
433
434
async def dispose(self):
    return await self._page._call(self._handle.dispose)

focus async

focus()
Source code in brimp/_async.py
440
441
async def focus(self):
    return await self._page._call(self._handle.focus)

get_attribute async

get_attribute(name)
Source code in brimp/_async.py
449
450
async def get_attribute(self, name):
    return await self._page._call(self._handle.get_attribute, name)

html async

html()
Source code in brimp/_async.py
458
459
async def html(self):
    return await self._page._call(self._handle.html)

invoke async

invoke(*args, this=undefined)
Source code in brimp/_async.py
418
419
async def invoke(self, *args, this=undefined):
    return await self._page._call(self._handle.invoke, *args, this=this)

json_value async

json_value()
Source code in brimp/_async.py
412
413
async def json_value(self):
    return await self._page._call(self._handle.json_value)

property async

property(name)
Source code in brimp/_async.py
421
422
async def property(self, name):
    return await self._page._call(self._handle.property, name)

property_names async

property_names()
Source code in brimp/_async.py
430
431
async def property_names(self):
    return await self._page._call(self._handle.property_names)

query_selector async

query_selector(selector)
Source code in brimp/_async.py
467
468
async def query_selector(self, selector):
    return await self._page._call(self._handle.query_selector, selector)

query_selector_all async

query_selector_all(selector)
Source code in brimp/_async.py
470
471
async def query_selector_all(self, selector):
    return await self._page._call(self._handle.query_selector_all, selector)

remove async

remove()
Source code in brimp/_async.py
464
465
async def remove(self):
    return await self._page._call(self._handle.remove)

set_attribute async

set_attribute(name, value)
Source code in brimp/_async.py
452
453
async def set_attribute(self, name, value):
    return await self._page._call(self._handle.set_attribute, name, value)

set_input_files async

set_input_files(files)
Source code in brimp/_async.py
446
447
async def set_input_files(self, files):
    return await self._page._call(self._handle.set_input_files, files)

set_property async

set_property(name, value)
Source code in brimp/_async.py
424
425
async def set_property(self, name, value):
    return await self._page._call(self._handle.set_property, name, value)

set_text_content async

set_text_content(text)
Source code in brimp/_async.py
461
462
async def set_text_content(self, text):
    return await self._page._call(self._handle.set_text_content, text)

text_content async

text_content()
Source code in brimp/_async.py
455
456
async def text_content(self):
    return await self._page._call(self._handle.text_content)

value async

value()
Source code in brimp/_async.py
409
410
async def value(self):
    return await self._page._call(self._handle.value)

Fingerprint data

The CLI manages fingerprint catalogs. This editable data class can be supplied as Session(profile=...) or embedded in a browser profile's network.fingerprint.

brimp.Fingerprint dataclass

Fingerprint(client: str = '', client_version: str = '', os: str = '', os_version: str = '', http_version: str = 'v2', tls_version: str = '1.2', tls_ciphers: list[str] = list(), tls_alpn: bool = True, tls_alps: bool = False, tls_cert_compression: list[str] = list(), tls_signature_hashes: list[str] = list(), tls_key_shares_limit: int = 2, tls_supported_groups: list[str] = list(), tls_session_ticket: bool = False, tls_extension_order: str = '', tls_delegated_credentials: list[str] = list(), tls_record_size_limit: int | None = None, tls_grease: bool = False, tls_use_new_alps_codepoint: bool = False, tls_signed_cert_timestamps: bool = False, tls_ech: str | None = None, tls_permute_extensions: bool = False, tls_trust_anchors: list[str] | None = None, headers: dict[str, str] = dict(), header_order: str = '', split_cookies: bool = False, form_boundary: str = '', http2_settings: str = '', http2_window_update: int = 0, http2_pseudo_headers_order: str = '', http2_stream_weight: int | None = None, http2_stream_exclusive: int | None = None, http2_no_priority: bool = False, http3_settings: str = '', http3_pseudo_headers_order: str = '', http3_tls_extension_order: str = '', http3_headers: dict[str, str] = dict(), http3_header_order: str = '', http3_tls_supported_groups: list[str] = list(), quic_transport_parameters: str = '', quic_cid_length: str | None = None, quic_initial_packet_number: int | None = None, ws_headers: dict[str, str] = dict(), ws_header_order: str = '', ws_disable_session_ticket: bool = False, ws_tls_cert_compression: list[str] | None = None, header_lang: str = '')

Editable TLS, HTTP/2, HTTP/3, QUIC and WebSocket fingerprint data.

Pass directly as Session(profile=...) or place it at profile["values"]["network"]["fingerprint"]. Use the CLI to manage Pro catalogs.

client class-attribute instance-attribute

client: str = ''

client_version class-attribute instance-attribute

client_version: str = ''

form_boundary class-attribute instance-attribute

form_boundary: str = ''

header_lang class-attribute instance-attribute

header_lang: str = ''

header_order class-attribute instance-attribute

header_order: str = ''

headers class-attribute instance-attribute

headers: dict[str, str] = field(default_factory=dict)

http2_no_priority class-attribute instance-attribute

http2_no_priority: bool = False

http2_pseudo_headers_order class-attribute instance-attribute

http2_pseudo_headers_order: str = ''

http2_settings class-attribute instance-attribute

http2_settings: str = ''

http2_stream_exclusive class-attribute instance-attribute

http2_stream_exclusive: int | None = None

http2_stream_weight class-attribute instance-attribute

http2_stream_weight: int | None = None

http2_window_update class-attribute instance-attribute

http2_window_update: int = 0

http3_header_order class-attribute instance-attribute

http3_header_order: str = ''

http3_headers class-attribute instance-attribute

http3_headers: dict[str, str] = field(default_factory=dict)

http3_pseudo_headers_order class-attribute instance-attribute

http3_pseudo_headers_order: str = ''

http3_settings class-attribute instance-attribute

http3_settings: str = ''

http3_tls_extension_order class-attribute instance-attribute

http3_tls_extension_order: str = ''

http3_tls_supported_groups class-attribute instance-attribute

http3_tls_supported_groups: list[str] = field(default_factory=list)

http_version class-attribute instance-attribute

http_version: str = 'v2'

os class-attribute instance-attribute

os: str = ''

os_version class-attribute instance-attribute

os_version: str = ''

quic_cid_length class-attribute instance-attribute

quic_cid_length: str | None = None

quic_initial_packet_number class-attribute instance-attribute

quic_initial_packet_number: int | None = None

quic_transport_parameters class-attribute instance-attribute

quic_transport_parameters: str = ''

split_cookies class-attribute instance-attribute

split_cookies: bool = False

tls_alpn class-attribute instance-attribute

tls_alpn: bool = True

tls_alps class-attribute instance-attribute

tls_alps: bool = False

tls_cert_compression class-attribute instance-attribute

tls_cert_compression: list[str] = field(default_factory=list)

tls_ciphers class-attribute instance-attribute

tls_ciphers: list[str] = field(default_factory=list)

tls_delegated_credentials class-attribute instance-attribute

tls_delegated_credentials: list[str] = field(default_factory=list)

tls_ech class-attribute instance-attribute

tls_ech: str | None = None

tls_extension_order class-attribute instance-attribute

tls_extension_order: str = ''

tls_grease class-attribute instance-attribute

tls_grease: bool = False

tls_key_shares_limit class-attribute instance-attribute

tls_key_shares_limit: int = 2

tls_permute_extensions class-attribute instance-attribute

tls_permute_extensions: bool = False

tls_record_size_limit class-attribute instance-attribute

tls_record_size_limit: int | None = None

tls_session_ticket class-attribute instance-attribute

tls_session_ticket: bool = False

tls_signature_hashes class-attribute instance-attribute

tls_signature_hashes: list[str] = field(default_factory=list)

tls_signed_cert_timestamps class-attribute instance-attribute

tls_signed_cert_timestamps: bool = False

tls_supported_groups class-attribute instance-attribute

tls_supported_groups: list[str] = field(default_factory=list)

tls_trust_anchors class-attribute instance-attribute

tls_trust_anchors: list[str] | None = None

tls_use_new_alps_codepoint class-attribute instance-attribute

tls_use_new_alps_codepoint: bool = False

tls_version class-attribute instance-attribute

tls_version: str = '1.2'

ws_disable_session_ticket class-attribute instance-attribute

ws_disable_session_ticket: bool = False

ws_header_order class-attribute instance-attribute

ws_header_order: str = ''

ws_headers class-attribute instance-attribute

ws_headers: dict[str, str] = field(default_factory=dict)

ws_tls_cert_compression class-attribute instance-attribute

ws_tls_cert_compression: list[str] | None = None