Python如何使用seleniumwire接管Chrome查看控制臺中參數(shù)
1、cmd打開控制臺,啟動谷歌并制定端口號,找不到文件的加環(huán)境變量
chrome.exe --remote-debugging-port=9222
2、獲取F12控制臺中接口參數(shù)
from selenium.webdriver.chrome.service import Service
from seleniumwire import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
chrome_options.set_capability("browserName", 'chrome')
chrome_options.set_capability("goog:chromeOptions", {'perfLoggingPrefs': {'enableNetwork': True}, 'w3c': False})
chrome_options.set_capability("goog:loggingPrefs", {"performance": "ALL"})
service = Service(executable_path='D:\crack-plugin\chromedriver-win64\chromedriver.exe')
driver = webdriver.Chrome(service=service, options=chrome_options)
driver.get("https://example.com")
print("已監(jiān)聽到網(wǎng)頁,名稱為:" + driver.title)
performance_log = driver.get_log('performance')
authorization = None
print(authorization)3、如果需要獲取針對性的參數(shù),比如header中的登錄令牌Bearer Token的話,進行針對性的寫法即可
for log in performance_log:
if "Authorization" in log['message']:
message = json.loads(log['message'])
if "Network.requestWillBeSentExtraInfo" == message['message']['method']:
bearer = message['message']['params']['headers']['Authorization']
authorization = bearer
print("獲取到登錄令牌:" + bearer)到此這篇關于Python使用seleniumwire接管Chrome查看控制臺中參數(shù)的文章就介紹到這了,更多相關Python seleniumwire控制臺內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
解決pycharm的Python console不能調試當前程序的問題
今天小編就為大家分享一篇解決pycharm的Python console不能調試當前程序的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-01-01
python GUI庫圖形界面開發(fā)之PyQt5下拉列表框控件QComboBox詳細使用方法與實例
這篇文章主要介紹了python GUI庫圖形界面開發(fā)之PyQt5下拉列表框控件QComboBox詳細使用方法與實例,需要的朋友可以參考下2020-02-02
python實現(xiàn)mp3文件播放的具體實現(xiàn)代碼
前段時間在搞一個基于python的語音助手,其中需要用到python播放音頻的功能,下面這篇文章主要給大家介紹了關于python實現(xiàn)mp3文件播放的具體實現(xiàn)代碼,需要的朋友可以參考下2023-05-05
使用Python opencv實現(xiàn)視頻與圖片的相互轉換
這篇文章主要介紹了使用Python opencv實現(xiàn)視頻與圖片的相互轉換,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-07-07
Python與Node.js之間實現(xiàn)通信的JSON數(shù)據(jù)接收發(fā)送
Python和Node.js是兩個流行且功能強大的編程語言,它們之間使用JSON格式進行數(shù)據(jù)交換是一種高效和靈活的方式,本文將詳細介紹如何在Python和Node.js之間通過JSON進行數(shù)據(jù)通信,包括發(fā)送和接收JSON數(shù)據(jù)以及一些常見的交互示例代碼2024-01-01
使用coverage統(tǒng)計python web項目代碼覆蓋率的方法詳解
這篇文章主要介紹了使用coverage統(tǒng)計python web項目代碼覆蓋率的方法,詳細分析了coverage的安裝以及coverage命令統(tǒng)計py文件相關操作技巧,需要的朋友可以參考下2019-08-08

