Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use execute_script on nodriver ? #1850

Open
mashien0201 opened this issue Apr 29, 2024 · 2 comments
Open

How to use execute_script on nodriver ? #1850

mashien0201 opened this issue Apr 29, 2024 · 2 comments

Comments

@mashien0201
Copy link

I looked through some nodriver source codes, but I didn’t seem to see any methods related to execute_script. Is it not possible to inject javascript into nodriver?

@gnori-zon
Copy link

gnori-zon commented Apr 29, 2024

dude, pls check nodriver.Tab.evaluate

async def evaluate(
        self, expression: str, await_promise=False, return_by_value=True
    ):
        remote_object, errors = await self.send(
            cdp.runtime.evaluate(
                expression=expression,
                user_gesture=True,
                await_promise=await_promise,
                return_by_value=return_by_value,
                allow_unsafe_eval_blocked_by_csp=True,
            )
        )
        if errors:
            raise ProtocolException(errors)

        if remote_object:
            if return_by_value:
                if remote_object.value:
                    return remote_object.value

            else:
                return remote_object, errors

You're welcome)

@mashien0201
Copy link
Author

@gnori-zon Thank you ! that work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants