""" @author: luojunhui """ import json import subprocess toutiao_js_path = "applications/crawler/toutiao/toutiao.js" def call_js_function(arguments_list): """ call js function """ # 将参数转换为JSON字符串 args_json = json.dumps(arguments_list) # 调用Node.js执行脚本 result = subprocess.run( ["node", toutiao_js_path, args_json], capture_output=True, text=True ) if result.returncode == 0: return result.stdout.strip() else: raise Exception(f"Error: {result.stderr}")