Closed collynash closed 2 weeks ago
Sure, here's a reproducible example:
from camoufox.async_api import AsyncCamoufox
from playwright.async_api import Response
async def handle_response(response: Response):
"""Processing code here"""
if response.request.method == 'GET':
print('GET request:', response.url)
async def run():
async with AsyncCamoufox() as browser:
page = await browser.new_page()
# Attach the event listener
page.on('response', handle_response)
await page.goto('https://example.com')
if __name__ == '__main__':
import asyncio
asyncio.run(run())
The Camoufox browser
is a drop in replacement for Playwright's browser. All new pages are Playwright pages, so your original Playwright code will work for it as well.
In playwright one can intercept network requests with something like this as follows:
How does one achieve something similar with camoufox to intercept target network request responses?