Skip to content

Decode Requests Body in SeleniumBase #3486

Closed
@ntdgo

Description

@ntdgo

I am trying to retrieve and decode the response body of requests using SeleniumBase. Below is the code I am using:

from seleniumbase import Driver

driver = Driver(wire=True)
driver.get("https://seleniumbase.io/demo_page")
for request in driver.requests:
    body_bytes = request.response.body
    str_body = body_bytes.decode("utf-8")
    print(request.url)
    print(str_body)
driver.quit()

Problem:

  • I want to extract the response body in a readable JSON or string format.
  • The above implementation retrieves the body but may not be in a structured format.

Expected Behavior:

  • The response body should be in a structured JSON or string format for easy processing.

How can I properly decode and parse the response body in JSON or as a readable string?
Thank you for your support!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    externalOutside SeleniumBase's scope. / Ask somewhere else.questionSomeone is looking for answers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions