Повторите в Json с помощью скрапа и селена - PullRequest
0 голосов
/ 13 марта 2020

Я пытался выполнить итерацию в json для извлечения необходимой мне информации, которая должна соответствовать следующим условиям:

Key = connectionId или Key = remoteConnectionId

value = 9093E2EF-E407-4F9B-A028-E233123C3D81 и значение! = Нет

connectionData не находится внутри json объекта

, а вот JSON, с которым я работаю:

{
"total": 66,
"scroll_id": null,
"rows": [
    {
        "messagingServer": "",
        "networkStatus": "21C20B388S000C000,21C20B388S000C000",
        "source": "com.lascondes.lascondes1-2.21",
        "clientVersion": "android-2.16.2.0",
        "variation": "attempt",
        "payload": {
            "socketId": "3FB7278C-130F-464D-AE9A-CE403B99F704"
        },
        "client": "native",
        "action": "connect",
        "proxyUrl": "",
        "ipWhitelist": "false",
        "iceConfig": "{\"includeServers\":\"all\",\"servers\":[],\"transportPolicy\":\"all\"}",
        "messagingUrl": "",
        "connectionId": "9093E2EF-E407-4F9B-A028-E233123C3D81",
        "guid": "ddd896c5-775d-4e12-9510-b76cf8947611",
        "deviceModel": "mfr=HUAWEI,model=JKM-LX3,abi=arm64-v8a",
        "apiServer": "api-standard.opentok.com",
        "clientSystemTime": "1584551231675",
        "component": "clientEvent",
        "timestamp": 1584551234121,
        "eventRemoteIp": "*****",
        "_InternalId__": "37852971396329782efa23ec2e4a0bb9f8b12b12c16602e",
        "dateParsed": "2020-03-18T10:07:14.121-07:00",
        "eventUuid": "e9e3136a-693a-11ea-aa24-0a6d27d997ec",
        "eventUserAgent": "otk_http/1.0",
        "eventName": "connect_attempt",
        "system": "JKM-LX3",
        "location": "Santiago, Santiago Metropolitan, Chile"
    },
    {
        "callType": "connectionCreated",
        "component": "serverEvent",
        "connectionId": "9093E2EF-E407-4F9B-A028-E233123C3D81",
        "connectionData": "paciente%3Da0H0P00000Rel4R",
        "connectionEventsSuppressed": "false",
        "eventName": "server_connectionCreated",
        "timestamp": 1584551235866
    },
    {
        "callType": "sessionCreated",
        "component": "serverEvent",
        "eventName": "server_sessionCreated",
        "minBitrate": "0",
        "timestamp": 1584551235866
    },
    {
        "messagingServer": "mantis007-pdx.tokbox.com",
        "networkStatus": "21C20B388S000C000,21C20B388S000C000_IPV4",
        "source": "com.lascondes.lascondes1-2.21",
        "clientVersion": "android-2.16.2.0",
        "variation": "success",
        "payload": {
            "socketId": "3FB7278C-130F-464D-AE9A-CE403B99F704"
        },
        "client": "native",
        "action": "connect",
        "proxyUrl": "",
        "ipWhitelist": "false",
        "p2p": "true",
        "iceConfig": "{\"includeServers\":\"all\",\"servers\":[{\"url\":\"turn:turn025-pdx.tokbox.com:3478?transport=udp\"},{\"url\":\"stun:turn025-pdx.tokbox.com:3478\"},{\"url\":\"turn:turn025-pdx.tokbox.com:443?transport=tcp\"},{\"url\":\"turns:turn025-pdx.tokbox.com:443?transport=tcp\"}],\"transportPolicy\":\"all\"}",
        "messagingUrl": "wss://mantis007-pdx.tokbox.com:443/rumorwebsocketsv2",
        "connectionId": "9093E2EF-E407-4F9B-A028-E233123C3D81",
        "guid": "ddd896c5-775d-4e12-9510-b76cf8947611",
        "deviceModel": "mfr=HUAWEI,model=JKM-LX3,abi=arm64-v8a",
        "apiServer": "api-standard.opentok.com",
        "attemptDuration": "2527",
        "clientSystemTime": "1584551234202",
        "component": "clientEvent",
        "timestamp": 1584551236907,
        "eventRemoteIp": "*****",
        "_InternalId__": "378529713973511bcf3068b2fade834245651f52ac8eb6a",
        "dateParsed": "2020-03-18T10:07:16.907-07:00",
        "eventUuid": "eb8c2d9e-693a-11ea-bbb2-0a65297c9614",
        "eventUserAgent": "otk_http/1.0",
        "eventName": "connect_success",
        "system": "JKM-LX3",
        "location": "Santiago, Santiago Metropolitan, Chile"
    },
    {
        "messagingServer": "mantis007-pdx.tokbox.com",
        "streamId": "A5FD1155-0CF3-41C1-BBC0-3AD2EBBB1175",
        "networkStatus": "21C20B388S000C000,21C20B388S000C000_IPV4",
        "source": "com.lascondes.lascondes1-2.21",
        "variation": "attempt",
        "client": "native",
        "action": "publish",
        "capturerStatus": "0",
        "p2p": "true",
        "messagingUrl": "wss://mantis007-pdx.tokbox.com:443/rumorwebsocketsv2",
        "connectionId": "9093E2EF-E407-4F9B-A028-E233123C3D81",
        "guid": "ddd896c5-775d-4e12-9510-b76cf8947611",
        "deviceModel": "mfr=HUAWEI,model=JKM-LX3,abi=arm64-v8a",
        "apiServer": "api-standard.opentok.com",
        "clientSystemTime": "1584551234715",
        "component": "clientEvent",
        "timestamp": 1584551237150,
        "_InternalId__": "378529713975632badc90869d4b6f378e71a15cc295a40e",
        "dateParsed": "2020-03-18T10:07:17.150-07:00",
        "eventUuid": "ebb134a2-693a-11ea-bbb2-0a65297c9614",
        "eventName": "publish_attempt",
        "widgetType": "publisher"
    },
    {
        "messagingServer": "mantis007-pdx.tokbox.com",
        "streamId": "A5FD1155-0CF3-41C1-BBC0-3AD2EBBB1175",
        "networkStatus": "21C20B388S000C000,21C20B388S000C000_IPV4",
        "source": "com.lascondes.lascondes1-2.21",
        "variation": "success",
        "client": "native",
        "action": "publish",
        "capturerStatus": "0",
        "p2p": "true",
        "messagingUrl": "wss://mantis007-pdx.tokbox.com:443/rumorwebsocketsv2",
        "connectionId": "9093E2EF-E407-4F9B-A028-E233123C3D81",
        "guid": "ddd896c5-775d-4e12-9510-b76cf8947611",
        "deviceModel": "mfr=HUAWEI,model=JKM-LX3,abi=arm64-v8a",
        "apiServer": "api-standard.opentok.com",
        "attemptDuration": "286",
        "clientSystemTime": "1584551235001",
        "component": "clientEvent",
        "timestamp": 1584551237436,
        "_InternalId__": "3785297139763740325e005d79ac5fccdd200494896ed0e",
        "dateParsed": "2020-03-18T10:07:17.436-07:00",
        "eventUuid": "ebdcf2a5-693a-11ea-aa24-0a6d27d997ec",
        "eventName": "publish_success",
        "widgetType": "publisher"
    },
    {
        "source": "https://consultas.mediclic.cl/citadoctor",
        "clientVersion": "js-2.16.3",
        "variation": "attempt",
        "clientInstanceId": "43e802f7-7931-4a34-bd6e-97bb105437b6",
        "action": "connect",
        "buildHash": "08194dfcf",
        "version": "v2.16.3",
        "connectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244",
        "guid": "bbabaacb-6799-42a0-a5e6-0649f6b324bc",
        "apiServer": "https://api-standard.opentok.com",
        "clientSystemTime": "1584552299180",
        "component": "clientEvent",
        "timestamp": 1584551993050,
        "eventRemoteIp": "*****",
        "_InternalId__": "3785297216922400f3ed88c7010c27c9b2bee77ff22249f",
        "dateParsed": "2020-03-18T10:19:53.050-07:00",
        "eventUuid": "ae3e8065-693c-11ea-9fe9-0ef5f4d130be",
        "eventUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36",
        "eventName": "connect_attempt",
        "system": "Chrome# MacOSX",
        "location": "Ecuador"
    },
    {
        "callType": "connectionCreated",
        "component": "serverEvent",
        "connectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244",
        "connectionData": "doctor%3Da0H0P00000Rel4R",
        "connectionEventsSuppressed": "false",
        "eventName": "server_connectionCreated",
        "timestamp": 1584551994737
    },
    {
        "messagingServer": "mantis007-pdx.tokbox.com",
        "streamId": "A5FD1155-0CF3-41C1-BBC0-3AD2EBBB1175",
        "source": "https://consultas.mediclic.cl/citadoctor",
        "variation": "attempt",
        "clientInstanceId": "43e802f7-7931-4a34-bd6e-97bb105437b6",
        "action": "subscribe",
        "buildHash": "08194dfcf",
        "subscriberId": "1b7b85ec-3c91-43b9-a83b-4b524760512b",
        "mediaServerName": "mantis007-pdx.tokbox.com",
        "version": "v2.16.3",
        "widgetType": "subscriber",
        "p2p": "true",
        "messagingUrl": "wss://mantis007-pdx.tokbox.com:443/rumorwebsocketsv2",
        "connectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244",
        "guid": "bbabaacb-6799-42a0-a5e6-0649f6b324bc",
        "apiServer": "https://api-standard.opentok.com",
        "clientSystemTime": "1584552301481",
        "component": "clientEvent",
        "timestamp": 1584551994967,
        "_InternalId__": "3785297216986633bd908248ecffb447ece49f4ab58c9bc",
        "dateParsed": "2020-03-18T10:19:54.967-07:00",
        "eventUuid": "af62f78d-693c-11ea-9fe9-0ef5f4d130be",
        "eventName": "subscribe_attempt"
    },
    {
        "callType": "subscriberCreated",
        "component": "serverEvent",
        "connectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244",
        "connectionData": "doctor%3Da0H0P00000Rel4R",
        "eventName": "server_subscriberCreated",
        "streamId": "A5FD1155-0CF3-41C1-BBC0-3AD2EBBB1175",
        "timestamp": 1584551995001,
        "widgetType": "subscriber"
    },
    {
        "messagingServer": "mantis007-pdx.tokbox.com",
        "source": "https://consultas.mediclic.cl/citadoctor",
        "clientVersion": "js-2.16.3",
        "variation": "success",
        "messagingServer": {
            "connectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244"
        },
        "clientInstanceId": "43e802f7-7931-4a34-bd6e-97bb105437b6",
        "action": "connect",
        "buildHash": "08194dfcf",
        "mediaServerName": "mantis007-pdx.tokbox.com",
        "ipWhitelist": "false",
        "version": "v2.16.3",
        "p2p": "true",
        "iceConfig": "{\"includeServers\":\"all\",\"servers\":[{\"url\":[\"turn:*****:3478?transport=udp\"]},{\"url\":[\"stun:*****:3478\"]},{\"url\":[\"turn:*****:443?transport=tcp\"]},{\"url\":[\"turns:turn025-pdx.tokbox.com:443?transport=tcp\"]}],\"transportPolicy\":\"all\"}",
        "messagingUrl": "wss://mantis007-pdx.tokbox.com:443/rumorwebsocketsv2",
        "connectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244",
        "guid": "bbabaacb-6799-42a0-a5e6-0649f6b324bc",
        "apiServer": "https://api-standard.opentok.com",
        "attemptDuration": "2305",
        "clientSystemTime": "1584552301485",
        "component": "clientEvent",
        "timestamp": 1584551995179,
        "eventRemoteIp": "*****",
        "_InternalId__": "3785297217007298e33d289108a11c470dd08a5c2b78615",
        "dateParsed": "2020-03-18T10:19:55.179-07:00",
        "eventUuid": "af834af8-693c-11ea-9fe9-0ef5f4d130be",
        "eventUserAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36",
        "eventName": "connect_success",
        "system": "Chrome# MacOSX",
        "location": "Ecuador"
    },
    {
        "peerId": "A5FD1155-0CF3-41C1-BBC0-3AD2EBBB1175",
        "messagingServer": "mantis007-pdx.tokbox.com",
        "streamId": "A5FD1155-0CF3-41C1-BBC0-3AD2EBBB1175",
        "source": "https://consultas.mediclic.cl/citadoctor",
        "variation": "attempt",
        "clientInstanceId": "43e802f7-7931-4a34-bd6e-97bb105437b6",
        "action": "createPeerConnection",
        "buildHash": "08194dfcf",
        "subscriberId": "1b7b85ec-3c91-43b9-a83b-4b524760512b",
        "mediaServerName": "mantis007-pdx.tokbox.com",
        "version": "v2.16.3",
        "peerPriority": "0",
        "widgetType": "subscriber",
        "p2p": "true",
        "messagingUrl": "wss://mantis007-pdx.tokbox.com:443/rumorwebsocketsv2",
        "connectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244",
        "guid": "bbabaacb-6799-42a0-a5e6-0649f6b324bc",
        "apiServer": "https://api-standard.opentok.com",
        "clientSystemTime": "1584552302267",
        "component": "clientEvent",
        "timestamp": 1584551996350,
        "_InternalId__": "3785297217052964e2cecc659bc09ee800c213b311da4a8",
        "dateParsed": "2020-03-18T10:19:56.350-07:00",
        "eventUuid": "b03603c7-693c-11ea-9fe9-0ef5f4d130be",
        "eventName": "createPeerConnection_attempt"
    },
    {
        "peerId": "A5FD1155-0CF3-41C1-BBC0-3AD2EBBB1175",
        "messagingServer": "mantis007-pdx.tokbox.com",
        "streamId": "A5FD1155-0CF3-41C1-BBC0-3AD2EBBB1175",
        "source": "https://consultas.mediclic.cl/citadoctor",
        "variation": "streamadded",
        "clientInstanceId": "43e802f7-7931-4a34-bd6e-97bb105437b6",
        "action": "createPeerConnection",
        "buildHash": "08194dfcf",
        "subscriberId": "1b7b85ec-3c91-43b9-a83b-4b524760512b",
        "mediaServerName": "mantis007-pdx.tokbox.com",
        "version": "v2.16.3",
        "peerPriority": "0",
        "widgetType": "subscriber",
        "p2p": "true",
        "messagingUrl": "wss://mantis007-pdx.tokbox.com:443/rumorwebsocketsv2",
        "connectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244",
        "guid": "bbabaacb-6799-42a0-a5e6-0649f6b324bc",
        "apiServer": "https://api-standard.opentok.com",
        "clientSystemTime": "1584552302308",
        "component": "clientEvent",
        "timestamp": 1584551996750,
        "_InternalId__": "3785297217063203eb629e09a7fef007ea52e79a8374cde",
        "dateParsed": "2020-03-18T10:19:56.750-07:00",
        "eventUuid": "b072f9e0-693c-11ea-9fe9-0ef5f4d130be",
        "eventName": "createPeerConnection_streamadded"
    },
    {
        "streamId": "A5FD1155-0CF3-41C1-BBC0-3AD2EBBB1175",
        "source": "https://consultas.mediclic.cl/citadoctor",
        "clientInstanceId": "43e802f7-7931-4a34-bd6e-97bb105437b6",
        "dataChannels": "{\"recvMessages\":0,\"sentMessages\":0}",
        "height": "150",
        "period": "1",
        "audioVolume": "100",
        "audioTrack": "true",
        "remoteConnectionId": "9093E2EF-E407-4F9B-A028-E233123C3D81",
        "subscriberId": "1b7b85ec-3c91-43b9-a83b-4b524760512b",
        "version": "v2.16.3",
        "widgetType": "subscriber",
        "subscribeToVideo": "true",
        "audioCodecChangeCount": "0",
        "messagingUrl": "wss://mantis007-pdx.tokbox.com:443/rumorwebsocketsv2",
        "connectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244",
        "guid": "bbabaacb-6799-42a0-a5e6-0649f6b324bc",
        "apiServer": "https://api-standard.opentok.com",
        "peerId": "A5FD1155-0CF3-41C1-BBC0-3AD2EBBB1175",
        "messagingServer": "mantis007-pdx.tokbox.com",
        "offerMessagesReceived": "1",
        "duration": "1",
        "videoCodecChangeCount": "0",
        "hasVideo": "true",
        "hasAudio": "true",
        "buildHash": "08194dfcf",
        "videoTrack": "true",
        "mediaServerName": "mantis007-pdx",
        "peerPriority": "0",
        "p2p": "true",
        "subscribeToAudio": "true",
        "width": "300",
        "clientSystemTime": "1584552303335",
        "component": "clientQos",
        "timestamp": 1584551997118,
        "_InternalId__": "378529721708824607706b697fd7597062d34f7c3e8411d",
        "dateParsed": "2020-03-18T10:19:57.118-07:00",
        "eventUuid": "b0ab40c7-693c-11ea-9fe9-0ef5f4d130be"
    },
    {
        "peerId": "A5FD1155-0CF3-41C1-BBC0-3AD2EBBB1175",
        "messagingServer": "mantis007-pdx.tokbox.com",
        "streamId": "A5FD1155-0CF3-41C1-BBC0-3AD2EBBB1175",
        "source": "https://consultas.mediclic.cl/citadoctor",
        "variation": "success",
        "payload": {
            "hasRelayCandidates": true,
            "pcc": 1370,
            "proxyInfo": ""
        },
        "clientInstanceId": "43e802f7-7931-4a34-bd6e-97bb105437b6",
        "action": "createPeerConnection",
        "buildHash": "08194dfcf",
        "subscriberId": "1b7b85ec-3c91-43b9-a83b-4b524760512b",
        "mediaServerName": "mantis007-pdx.tokbox.com",
        "version": "v2.16.3",
        "peerPriority": "0",
        "widgetType": "subscriber",
        "p2p": "true",
        "messagingUrl": "wss://mantis007-pdx.tokbox.com:443/rumorwebsocketsv2",
        "connectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244",
        "guid": "bbabaacb-6799-42a0-a5e6-0649f6b324bc",
        "apiServer": "https://api-standard.opentok.com",
        "clientSystemTime": "1584552303637",
        "component": "clientEvent",
        "timestamp": 1584551997304,
        "_InternalId__": "37852972170931671832b6ca0683fe56da2e77ee531cd58",
        "dateParsed": "2020-03-18T10:19:57.304-07:00",
        "eventUuid": "b0c786f1-693c-11ea-9fe9-0ef5f4d130be",
        "eventName": "createPeerConnection_success"
    },
    {
        "messagingServer": "mantis007-pdx.tokbox.com",
        "streamId": "A5FD1155-0CF3-41C1-BBC0-3AD2EBBB1175",
        "source": "https://consultas.mediclic.cl/citadoctor",
        "variation": "success",
        "clientInstanceId": "43e802f7-7931-4a34-bd6e-97bb105437b6",
        "action": "subscribe",
        "buildHash": "08194dfcf",
        "subscriberId": "1b7b85ec-3c91-43b9-a83b-4b524760512b",
        "mediaServerName": "mantis007-pdx.tokbox.com",
        "version": "v2.16.3",
        "widgetType": "subscriber",
        "p2p": "true",
        "messagingUrl": "wss://mantis007-pdx.tokbox.com:443/rumorwebsocketsv2",
        "connectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244",
        "guid": "bbabaacb-6799-42a0-a5e6-0649f6b324bc",
        "apiServer": "https://api-standard.opentok.com",
        "attemptDuration": "3594",
        "clientSystemTime": "1584552305075",
        "component": "clientEvent",
        "timestamp": 1584551998561,
        "_InternalId__": "378529721714017c8ed662b33675b12570134e66c3d1d9f",
        "dateParsed": "2020-03-18T10:19:58.561-07:00",
        "eventUuid": "b1876b4f-693c-11ea-9fe9-0ef5f4d130be",
        "eventName": "subscribe_success"
    },
    {
        "framesRendered": "22376",
        "streamId": "A5FD1155-0CF3-41C1-BBC0-3AD2EBBB1175",
        "videoHeight": "0",
        "videoWidth": "0",
        "videoLocalAddress": "*****:1029",
        "cpuDevice": "-1",
        "height": "0",
        "period": "0",
        "videoRemoteRelayProtocol": "TURN/UDP",
        "capturerDroppedFrames": "0",
        "remoteConnectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244",
        "widgetType": "publisher",
        "capturerFrameRate": "30",
        "videoAvgEncodeMs": "0",
        "videoLocalCandidateType": "prflx",
        "messagingUrl": "wss://mantis007-pdx.tokbox.com:443/rumorwebsocketsv2",
        "cpuTotal": "-1",
        "connectionId": "9093E2EF-E407-4F9B-A028-E233123C3D81",
        "cpuSystem": "-1",
        "networkStatus": "21C20B388S000C000,21C20B388S000C000_IPV4",
        "audioTransportType": "udp",
        "videoSentBytes": "0",
        "offerMessagesReceived": "1",
        "audioRemoteRelayProtocol": "TURN/UDP",
        "videoTransportType": "udp",
        "audioLocalCandidateType": "prflx",
        "memoryResident": "-1",
        "cpuUser": "-1",
        "videoHeightInput": "640",
        "videoRtt": "402",
        "videoCaptureJitterMs": "",
        "videoCodec": "VP8",
        "audioRemoteAddress": "*****:65198",
        "videoTrack": "true",
        "framesCapturedMetadata": "0",
        "audioLocalAddress": "*****:1029",
        "width": "0",
        "videoEncodeUsagePercent": "0",
        "deviceModel": "mfr=HUAWEI,model=JKM-LX3,abi=arm64-v8a",
        "clientSystemTime": "1584551996345",
        "audioRemoteCandidateType": "relay",
        "videoSentEstimatedBandwidth": "300000",
        "source": "com.lascondes.lascondes1-2.21",
        "srtpCipher": "AES_CM_128_HMAC_SHA1_80",
        "audioLocalRelayProtocol": "",
        "videoSource": "Camera",
        "audioRtt": "402",
        "videoRemoteAddress": "*****:65198",
        "scalableVideo": "false",
        "framesCaptured": "22376",
        "videoLocalRelayProtocol": "",
        "audioTrack": "true",
        "cpuLimitedResolution": "false",
        "audioCodecChangeCount": "0",
        "cpuCores": "-1",
        "videoSentPacketsLost": "0",
        "capturerProcessTime": "0",
        "guid": "ddd896c5-775d-4e12-9510-b76cf8947611",
        "apiServer": "api-standard.opentok.com",
        "peerId": "1b7b85ec-3c91-43b9-a83b-4b524760512b",
        "messagingServer": "mantis007-pdx.tokbox.com",
        "remoteSubscriberId": "1b7b85ec-3c91-43b9-a83b-4b524760512b",
        "audioSentBytes": "0",
        "memoryVirtual": "-1",
        "numSubscribers": "0",
        "duration": "0",
        "actualEncBitrate": "0",
        "videoRemoteCandidateType": "relay",
        "videoCodecChangeCount": "0",
        "client": "native",
        "videoBandwidthLimitedResolution": "false",
        "audioSentPackets": "0",
        "hasVideo": "true",
        "hasAudio": "true",
        "videoCaptureQueueDelayMsPerS": "",
        "capturerOverusing": "0",
        "audioSentPacketsLost": "0",
        "videoFrameRate": "0",
        "peerPriority": "0",
        "p2p": "true",
        "videoWidthInput": "480",
        "videoSentPackets": "0",
        "component": "clientQos",
        "timestamp": 1584551998827,
        "_InternalId__": "3785297217147271e41f2d7a9d50be557b8d2a5087cb9c2",
        "dateParsed": "2020-03-18T10:19:58.827-07:00",
        "eventUuid": "b1afe45d-693c-11ea-bbb3-0a65297c9614",
        "videoPacketlossPercentage": 0,
        "audioPacketlossPercentage": 0,
        "packetlossPercentage": 0,
        "rtt": 402
    },
    {
        "messagingServer": "mantis007-pdx.tokbox.com",
        "streamId": "2ca0845c-d15f-40c0-bb5f-7f9e957dcd3d",
        "source": "https://consultas.mediclic.cl/citadoctor",
        "variation": "attempt",
        "payload": {
            "properties": {
                "audioFallbackEnabled": true,
                "classNames": "OT_root OT_publisher",
                "constraints": {
                    "audio": true,
                    "video": true
                },
                "disableAudioProcessing": false,
                "enableRenegotiation": false,
                "enableStereo": false,
                "fitMode": "cover",
                "height": "160px",
                "insertDefaultUI": true,
                "insertMode": "replace",
                "mirror": true,
                "publishAudio": true,
                "publishVideo": true,
                "showControls": true,
                "width": "120px"
            }
        },
        "clientInstanceId": "43e802f7-7931-4a34-bd6e-97bb105437b6",
        "action": "publish",
        "buildHash": "08194dfcf",
        "mediaServerName": "mantis007-pdx.tokbox.com",
        "version": "v2.16.3",
        "widgetType": "publisher",
        "p2p": "true",
        "messagingUrl": "wss://mantis007-pdx.tokbox.com:443/rumorwebsocketsv2",
        "connectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244",
        "guid": "bbabaacb-6799-42a0-a5e6-0649f6b324bc",
        "apiServer": "https://api-standard.opentok.com",
        "clientSystemTime": "1584552311587",
        "component": "clientEvent",
        "timestamp": 1584552005073,
        "_InternalId__": "378529728450675588464a099b2e38ce0b738f1c33a0a5a",
        "dateParsed": "2020-03-18T10:20:05.073-07:00",
        "eventUuid": "b56904c2-693c-11ea-9fe9-0ef5f4d130be",
        "eventName": "publish_attempt"
    },
    {
        "callType": "publisherCreated",
        "component": "serverEvent",
        "connectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244",
        "connectionData": "doctor%3Da0H0P00000Rel4R",
        "eventName": "server_publisherCreated",
        "minBitrate": "0",
        "streamId": "2ca0845c-d15f-40c0-bb5f-7f9e957dcd3d",
        "source": "camera",
        "timestamp": 1584552006121,
        "widgetType": "publisher"
    },
    {
        "messagingServer": "mantis007-pdx.tokbox.com",
        "streamId": "2ca0845c-d15f-40c0-bb5f-7f9e957dcd3d",
        "source": "https://consultas.mediclic.cl/citadoctor",
        "variation": "success",
        "payload": {
            "audioInputDeviceCount": 2,
            "audioInputDevices": [
                {
                    "deviceId": "default",
                    "kind": "audioInput",
                    "label": "Predeterminado - Internal Microphone (Built-in)"
                },
                {
                    "deviceId": "69cf5fb06a7aacb51e1dff3197c293214851902de6a8026f92d5e16d7bdca4bb",
                    "kind": "audioInput",
                    "label": "Internal Microphone (Built-in)"
                }
            ],
            "selectedAudioInputDeviceId": "default",
            "videoInputDeviceCount": 0,
            "videoInputDevices": []
        },
        "clientInstanceId": "43e802f7-7931-4a34-bd6e-97bb105437b6",
        "action": "publish",
        "buildHash": "08194dfcf",
        "mediaServerName": "mantis007-pdx.tokbox.com",
        "version": "v2.16.3",
        "widgetType": "publisher",
        "p2p": "true",
        "messagingUrl": "wss://mantis007-pdx.tokbox.com:443/rumorwebsocketsv2",
        "connectionId": "d0d8e546-0a95-49d0-b008-c5bb40057244",
        "guid": "bbabaacb-6799-42a0-a5e6-0649f6b324bc",
        "apiServer": "https://api-standard.opentok.com",
        "attemptDuration": "1200",
        "clientSystemTime": "1584552312786",
        "component": "clientEvent",
        "timestamp": 1584552006273,
        "_InternalId__": "378529728455283d431c99cc1b56ccad635caee5716fefa",
        "dateParsed": "2020-03-18T10:20:06.273-07:00",
        "eventUuid": "b6202a11-693c-11ea-9fe9-0ef5f4d130be",
        "eventName": "publish_success"
    },
    {
        "callType": "subscriberCreated",
        "component": "serverEvent",
        "connectionId": "9093E2EF-E407-4F9B-A028-E233123C3D81",
        "connectionData": "paciente%3Da0H0P00000Rel4R",
        "eventName": "server_subscriberCreated",
        "streamId": "2ca0845c-d15f-40c0-bb5f-7f9e957dcd3d",
        "timestamp": 1584552006379,
        "widgetType": "subscriber"
    } ]

Это код, который я сейчас использую

def parse(self, response):
    json_metrics = json.loads(response.body)['rows']
    for a in json_metrics:
        try:
            if 'paciente' in a['connectionData']:
                valor = a.get('connectionId')
        except:
            print('exception1')
    for b in json_metrics:
        try:
            for key, value in b.items():
                if key == 'connectionId' or key == 'remoteConnectionId' and value == valor or value is not None and 'connectionData' not in b:
                    rtt = b.get('rtt')
                    yield{
                        'rtt': rtt
                    }
        except:
            print('exception2')

1 Ответ

0 голосов
/ 13 марта 2020

Я считаю, что это ошибка вставки копии - вам не хватает "]} " в конце вашего JSON.

Во-вторых, попробуйте этот код:

json_info = json.loads(response.body)
total = json_info['total']
print (total)

Более того, вот как вы можете получить ' networkStatus ':

for x in json_info['rows']:
    try:
        # try..except...since not all rows elements have 'networkStatus'
        print (x['networkStatus'])
    except:
        pass

Вот еще один подход с использованием re.findall):

network_statuses = re.findall( r"networkStatus.:.([^\"]+)", response.body, re.M)
print ( ",".join(network_statuses) )

Будет выведено «WiFi, WiFi_IPV4» - обратите внимание, что вместо преобразования JSON этот подход напрямую использует « response.body ».

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...