ClericPy / ichrome

Chrome controller for Humans, based on Chrome Devtools Protocol(CDP) and python3.7+.
https://pypi.org/project/ichrome/
MIT License
228 stars 29 forks source link

iter_fetch for Fetch.enable #74

Closed ClericPy closed 2 years ago

ClericPy commented 2 years ago

https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-enable

ClericPy commented 2 years ago
import asyncio
import json

from ichrome import AsyncChromeDaemon

async def main():
    async with AsyncChromeDaemon() as cd:
        async with cd.connect_tab() as tab:
            async with tab.iter_fetch(timeout=5) as f:
                await tab.goto('http://httpbin.org/get', timeout=0)
                async for request in f:
                    print(json.dumps(request))
                    await f.continueRequest(request)

if __name__ == "__main__":
    asyncio.run(main())