我的代碼:
from selenium import webdriver
import sys
import time
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.webdriver.chrome.options import Options
import os
import json
chrm_options=Options()
chrm_caps = webdriver.DesiredCapabilities.CHROME.copy()
chrm_caps['goog:loggingPrefs'] = { 'performance':'ALL' }
#driver = webdriver.Chrome(executable_path = 'chromedriver.exe', chrome_options=chrm_options,desired_capabilities=chrm_caps) Windows
driver = webdriver.Chrome(executable_path = 'C:\chromedriver.exe', chrome_options=chrm_options,desired_capabilities=chrm_caps) #Linux
def LoadWebDriver() :
print("Web driver Init ")
base_url = "https://pocketoption.com/en/cabinet/demo-quick-high-low/#td" #Change the site
print('Loading URL ....')
driver.get(base_url )
def WebSocketLog():
for wsData in driver.get_log('performance'):
#print(wsData)
wsJson = json.loads((wsData['message']))
print(wsData)
# if wsJson["message"]["method"]== "Network.webSocketFrameReceived":
# print ("Rx :" str(wsJson["message"]["params"]["timestamp"]) wsJson["message"]["params"]["response"]["payloadData"])
# if wsJson["message"]["method"] =="Network.webSocketFrameSent":
# print ("Tx :" wsJson["message"]["params"]["response"]["payloadData"])
LoadWebDriver()
print("Waiting")
time.sleep(30) #Capture messages for 30sec, integrate your code here
收到訊息:
Rx :451-["updateStream",{"_placeholder":true,"num":0}]
Rx :W1siQVVEQ0hGIiwxNjMzNTI1MDg2LjM2NiwwLjY3Mjc4XV0=
Rx :451-["updateStream",{"_placeholder":true,"num":0}]
Rx :W1siQVVEQ0hGIiwxNjMzNTI1MDg2LjU0NywwLjY3MjgxXV0=
Rx :451-["updateStream",{"_placeholder":true,"num":0}]
Rx :W1siQVVEQ0hGIiwxNjMzNTI1MDg2LjY5NywwLjY3Mjc5XV0=
Rx :451-["updateStream",{"_placeholder":true,"num":0}]
Rx :W1siQVVEQ0hGIiwxNjMzNTI1MDg3LjU2NiwwLjY3Mjc5XV0=
在 pupter 訊息中是上帝,但在 selenium 中就像這樣
uj5u.com熱心網友回復:
嗨,Rx 值看起來像 base64 編碼的字串。使用下面的函式后,我得到了這個值,這是你期望的嗎?
[[“澳元”,1633525087.566,0.67279]]
import base64
def base64ToString(b):
return base64.b64decode(b).decode('utf-8')
b = "W1siQVVEQ0hGIiwxNjMzNTI1MDg3LjU2NiwwLjY3Mjc5XV0="
print(base64ToString(b))
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/311621.html
上一篇:Java-Selenium-無法找到與CDP版本94完全匹配的版本,因此回傳找到的最接近的版本:93
下一篇:查找表硒時找不到元素
