首页 > 解决方案 > 如何将数组列表从 chrome 扩展发送到我的 python 应用程序?

问题描述

我正在尝试使用本机消息 api 将数组列表从 chrome 扩展发送到我的本机 python 应用程序。

背景脚本.js

port = window.browser.runtime.connectNative(hostName);
port.postMessage(request.attributes);

我的应用程序.py

text_length_bytes = sys.stdin.read(4)
text_length = struct.unpack('i', bytes(text_length_bytes, 'utf-8'))[0]
text = sys.stdin.read(text_length)

当我在帖子消息中发送数组列表作为属性时,chrome 扩展程序和本机 python 应用程序之间的连接停止,但是当我将字符串作为属性时它可以工作。

标签: google-chromegoogle-chrome-extensionchrome-native-messaging

解决方案


推荐阅读