Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从WebKitNetworkRequest获取POST数据_Python_Webkit - Fatal编程技术网

Python 从WebKitNetworkRequest获取POST数据

Python 从WebKitNetworkRequest获取POST数据,python,webkit,Python,Webkit,我正试图通过HTTP请求将数据从运行在GTK webkit中的javascript应用程序发送到Python,并以POST方式发送数据 我可以使用资源请求启动并检查请求的uri来捕获请求 我知道请求是有效的,因为我可以通过请求头发送数据,并使用 def on_resource_request_starting(view, frame, resource, request, response): uri = urllib.unquote(request.props.uri) if

我正试图通过HTTP请求将数据从运行在GTK webkit中的javascript应用程序发送到Python,并以POST方式发送数据

我可以使用
资源请求启动
并检查请求的uri来捕获请求

我知道请求是有效的,因为我可以通过请求头发送数据,并使用

def on_resource_request_starting(view, frame, resource, request, response):
    uri = urllib.unquote(request.props.uri)
    if uri.startswith('http://appname.local/'):
        print request.get_message().request_headers.get_one('foobar')
但是当我使用
print request.get_message().request_body.data
时,我什么也得不到


如何查看POST数据?

我没有使用此API,但我相信您需要在读取
数据
字段之前调用绑定的等价物
soup\u message\u body\u flant()
。请参阅C API中有关的文档

因此,猜测一下:

print request.get_message().request_body.flatten().data
挂接到SoupSession“request queued”信号并获取 使用soup\u message\u body\u get\u chunk(soupmsgbody,num)的缓冲区; 似乎有效(在今天的webkitgtk1中,2015年6月)。
webkit_get_default_session()返回有问题的SoupSession。

如果找到答案,请发布答案