Python解码AMF响应

2024-04-29 06:57:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我用python向一个返回AMF的web服务发出请求。我不知道是AMF0还是AMF3。在

r = requests.post(url, data=data)
>>> r.text
u'\x00\x03...'

Full data here

如何将r.text转换为python对象或类似对象?我找到了amfast,但它的Decoder类返回一个3.131513074181806e-294,假设AMF0和None为AMF3。(两者都不正确)

^{pr2}$

Tags: 对象textweburldataherepostrequests
2条回答

你试过PyAMF吗。在

from pyamf import remoting
remoting.decode(data)

我看到您的代码有两个问题,第一个是使用r.text返回二进制数据。请改用r.content。第二个问题是使用decoder.decode方法,它解码一个对象而不是一个包。请改用decoder.decode_packet。在

from amfast.decoder import Decoder
decoder = Decoder(amf3=True)
obj = decoder.decode_packet(r.content)

使用Pyamf也可以,使用r.content。在

相关问题 更多 >