Replies: 1 comment
-
Managed to figure it out myself, you can use from functools import partial
import asyncio
from pydoll.browser.chrome import Chrome
from pydoll.events.network import NetworkEvents
from pydoll.commands.network import NetworkCommands
async def on_response(page, event):
request_id = event['params']['requestId']
data = await page._execute_command(
NetworkCommands.get_response_body(request_id=request_id)
)
async def main():
async with Chrome() as browser:
await browser.start()
await page.enable_network_events()
await page.on(NetworkEvents.RESPONSE_RECEIVED, partial(on_response, page))
page = await browser.get_page()
await page.go_to("https://www.example.com")
if __name__ == "__main__":
asyncio.run(main()) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to access JSON data that is returned from a response after going to a webpage, what would be the correct way of doing this? I'm currently enabling network events and monitoring network requests using
NetworkEvents.RESPONSE_RECEIVED
. While the docstring for this mentions that the event contains details about the body of the response, I don't see the expected JSON data in the event dictionary.Beta Was this translation helpful? Give feedback.
All reactions