Comments (7)
from undetected-chromedriver.
Return cdp.fetch.continue_request(request_id=event.request_id)
Needs to be awaited. Not tested but 99% sure
Edit: you are returning a bare CDP command as well. You need to tab.send it as well
from undetected-chromedriver.
The code below simply hangs instead of continuing.
async def receive_handler(event: cdp.fetch.RequestPaused, tab): print(event.resource_type) return await tab.send(cdp.fetch.continue_request(request_id=event.request_id)) async def main(): options = Options() service = Service('C:\Program Files\Google\Chrome\Application\chrome.exe') driver = await start( service=service, options=options, ) await cdp.fetch.enable() tab = driver.main_tab tab.add_handler(lambda e: receive_handler(e, tab)) page = await driver.get('https://abrahamjuliot.github.io/creepjs/') input("Press Enter to continue...") await page.close() if __name__ == '__main__': loop().run_until_complete(main())
And forgot some awaits. Untested corrected code above
from undetected-chromedriver.
Doesn't work, it says RuntimeWarning: coroutine 'receive_handler' was never awaited
from undetected-chromedriver.
Alright I just moved the receive_handler function into the main function and it works now, it's probably better to make a whole class instead.
Thanks for help!
from undetected-chromedriver.
Hmm this is odd, it "should" work now but the site never loads, rather it's stuck on loading indefinitely.
I wonder what's causing this?
from undetected-chromedriver.
this works
from nodriver import *
import asyncio
def receive_handler(event: cdp.fetch.RequestPaused, tab):
print(event.resource_type)
asyncio.ensure_future(tab.send(cdp.fetch.continue_request(request_id=event.request_id)))
async def main():
driver = await start(
)
tab = driver.main_tab
driver.main_tab.add_handler(cdp.fetch.RequestPaused, lambda e: receive_handler(e, tab))
await tab.get('https://abrahamjuliot.github.io/creepjs/')
input("Press Enter to continue...")
await tab.close()
if __name__ == '__main__':
loop().run_until_complete(main())
ofcourse it would make more sense to encapsulate it in a class
from undetected-chromedriver.
Related Issues (20)
- How does nodriver switch iframes? Does the “.switch_to.frame” function exist? HOT 1
- Running multiple drivers at once creating a Remote Connection Close with no Response Exception
- NoDriver Proxy support? HOT 2
- [NoDriver] How to add headers to page? HOT 1
- AttributeError: module 'selenium' has no attribute 'webdriver'
- [Nodriver] Why does the number of browser.tabs remain unchanged after "Page" close?
- [Nodriver]:There is a bug in browser.cookies.set_all() HOT 1
- [Nodriver] How to use disable-web-security?
- I'm unable to download the chrome_driver after packaging with Nuitka. HOT 2
- [Nodriver] How to execute cdp command ? HOT 1
- The default is to download the corresponding chromedirvier, but now there is a problem HOT 2
- [NoDriver] Element.send_keys() works unexpectedly
- [NoDriver] Getting detected after couple logins HOT 3
- [NoDriver] Cannot bypass cloudflare on any website HOT 9
- user-data-dir parameter HOT 1
- Bet365
- I try use your example code, but it don't work...
- [NoDriver] performance decreases after sequentially created browser instances. HOT 1
- [NoDriver] - get_position(), save_screenshot() may be incorrect
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from undetected-chromedriver.