Skip to content

[nodriver] Retrieving response body from response #1976

Answered by lunden23
lunden23 asked this question in Q&A
Discussion options

You must be logged in to vote

I managed to solve it. I had to create an asyncio task for it to make it work, here is my current quick and dirty solution:

    async def scrape_data(self, certificate_id: str) -> dict[str, Any]:
        # Network event handlers
        await self._main_tab.send(nodriver.cdp.network.enable())
        self._main_tab.add_handler(nodriver.cdp.network.ResponseReceived, self._receive_handler)
        await self._main_tab.get(f"{self._manager.config.url_base}{example}&locale=en_US")

        # Check that correct response is received by polling until _receive_task is set or timeout occurs
        timeout = 10
        start_time = asyncio.get_running_loop().time()
        while self._receive_task is

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@lunden23
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by lunden23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants