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ù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
Python 統(tǒng)計位數(shù)為偶數(shù)的數(shù)字代碼詳解
這篇文章主要介紹了Python 統(tǒng)計位數(shù)為偶數(shù)的數(shù)字,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-03-03
python使用Windows的wmic命令監(jiān)控文件運行狀況,如有異常發(fā)送郵件報警
這篇文章主要介紹了python使用Windows的wmic命令監(jiān)控文件運行狀況,如有異常發(fā)送郵件報警的示例,幫助大家更好的理解和使用python,感興趣的朋友可以了解下2021-01-01
Python學習筆記整理3之輸入輸出、python eval函數(shù)
這篇文章主要介紹了Python學習筆記整理3之輸入輸出、python eval函數(shù)的相關資料,需要的朋友可以參考下2015-12-12
TensorFlow實現(xiàn)RNN循環(huán)神經(jīng)網(wǎng)絡
這篇文章主要介紹了TensorFlow實現(xiàn)RNN循環(huán)神經(jīng)網(wǎng)絡,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-02-02
Python使用requests庫發(fā)送請求的示例代碼
與原生的urllib庫相比,requests庫提供了更簡潔、易于理解和使用的API,使發(fā)送HTTP請求變得更加直觀和高效,所以本文給大家介紹了Python如何使用requests庫發(fā)送請求,需要的朋友可以參考下2024-03-03
Django同時連接多種數(shù)據(jù)庫的實現(xiàn)
在開發(fā)Django項目的時候,很多時候都是使用一個數(shù)據(jù)庫,即settings 中只有default數(shù)據(jù)庫,但是有一些項目確實也需要使用多個數(shù)據(jù)庫,本文主要介紹了Django同時連接多種數(shù)據(jù)庫的實現(xiàn),感興趣的可以了解一下2023-11-11

