用AioWebSocket模拟websocket请求没有返回网页数据

我用python的AioWebSocket请求这个网站 https://www.vueling.com/en/we-are-vueling/contact/management?helpCenterFlow=RefundAirportTaxes 其中有客服智能回答的websocket协议,但是返回的数据和浏览器的不同。
我用python返回的是

img


浏览器返回的是

img


我写的代码是

import asyncio
import logging
from datetime import datetime
from aiowebsocket.converses import AioWebSocket
import execjs
ctx = execjs.compile(open('111.js').read())
code = ctx.call('get_id')

async def startup(uri):
    async with AioWebSocket(uri) as aws:
        converse = aws.manipulator #初始化 aiowebsocket 库的连接类
        message = str([
  "processInput",
  {
    "URLToken": "cba92de4473675f50885b02f529f57aa0bb5bd878e9e0d65a4c4a19b62feabcd",
    "userId": code.get('userId'),
    "sessionId": code.get('sessionId'),
    "channel": "webchat-client",
    "source": "device",
    "passthroughIP": 'null',
    "reloadFlow": 'false',
    "resetFlow": 'false',
    "resetState": 'false',
    "resetContext": 'false',
    "text": "GET_STARTED",
    "data": {
      "culture": "en-GB",
      "helpCenterFlow": "RefundAirportTaxes",
      "type": 'null',
      "subType": 'null',
      "clientTarget": 'null'
    }
  }
])
        while True: # 不断地向服务器发送信息,并打印输出信息的内容和时间
            await converse.send(message)
            print('{time}-Client send:{message}'.format(time=datetime.now().strftime('%Y-%m-%d %H:%M:%S'),message=message))

            # 不断的读取服务器推送给客户端的信息,并打印输出信息的内容和时间
            mes = await converse.receive()
            print('{time}-Client receive:{rec}'.format(time=datetime.now().strftime('%Y-%m-%d %H:%M:%S'),rec=mes))

if __name__ == '__main__':
    remote = 'wss://endpoint-v4-chatbot.vueling.com/socket.io/?EIO=3&transport=websocket' #设定远程服务器的地址

    try: # 开启事件循环,调用指定的方法
        asyncio.get_event_loop().run_until_complete(startup(remote))
    except KeyboardInterrupt as exc:
        logging.info('Quit.')

调用的js文件是

var ff = function ()  {
    i = new Array(16);
n = 0
for (var t; n < 16; n++){
        t = 4294967296 * Math.random(),
        i[n] = t >>> ((3 & n) << 3) & 255;

    }
return i
}
function v4(n, t, i){
    if ("string" == typeof n && (t = "binary" === n ? new Array(16) : null,
        n = null),
        f = ff(),
        f[6] = 15 & f[6] | 64,
        f[8] = 63 & f[8] | 128,
        t)
            for (e = 0; e < 16; ++e)
                t[o + e] = f[e];
        return u(f)

}

 var u = function(n, t) {
     for (var i = [], t = 0; t < 256; ++t)
        i[t] = (t + 256).toString(16).substr(1)
        var r = 0
          , u = i;
        return [u[n[r++]], u[n[r++]], u[n[r++]], u[n[r++]], "-", u[n[r++]], u[n[r++]], "-", u[n[r++]], u[n[r++]], "-", u[n[r++]], u[n[r++]], "-", u[n[r++]], u[n[r++]], u[n[r++]], u[n[r++]], u[n[r++]], u[n[r++]]].join("")
    }
function get_id(){
    return {
        'userId': "user-".concat(v4()),
        'sessionId': "session-".concat(v4()),
    }
}
console.log(get_id())

我想问下我带了userid和sessionid,为什么还是得不到和浏览器一样的数据,我该怎么才能做到,我发一些消息,客服回消息我python端都能收到

1、做一个喂狗判断【监听websocket返回的数据是否有变化】
2、检查websocket长连接的session与登录时的session是否一致

你的目标网站桌面登录的啊,我进入不了

img


我挂了梯子都上不去

这篇文章或许可以提供一些新思路 https://blog.csdn.net/mouday/article/details/90047100

这篇文章或许可以提供一些新思路

你那是什么语言的代码我可以帮你解决问题

无法访问网站