How does python execute the javascript code and get the console output of js?

this library can execute js, but cannot get console output
https://pypi.org/project/PyEx.

seems to be a similar problem:
from-python" rel=" nofollow noreferrer "> https://stackoverflow.com/que.

Apr.26,2021

cannot be executed directly, so why don't you change your way of thinking, open the browser through selenium and execute it in the browser, then you can get everything you want.


what about the answer on

Stack Overflow?


if you only take the console output, you can call nodejs to execute javascript, such as

-sharp -*- coding: utf-8 -*-
from subprocess import Popen, PIPE

script = '''
console.log('hi');
'''

p = Popen(['node'], stdin=PIPE, stdout=PIPE, stderr=PIPE)
out, err = p.communicate(script.encode())
print(f'{out}\n{err}\n')
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c0e1-2c2e8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c0e1-2c2e8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?