欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Python如何使用seleniumwire接管Chrome查看控制臺(tái)中參數(shù)

 更新時(shí)間:2025年01月20日 14:23:19   作者:NUZGNAW  
文章介紹了如何使用Python的seleniumwire庫來接管Chrome瀏覽器,并通過控制臺(tái)查看接口參數(shù),本文給大家介紹的非常詳細(xì),感興趣的朋友跟隨小編一起看看吧

1、cmd打開控制臺(tái),啟動(dòng)谷歌并制定端口號(hào),找不到文件的加環(huán)境變量

chrome.exe --remote-debugging-port=9222

2、獲取F12控制臺(tái)中接口參數(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、如果需要獲取針對(duì)性的參數(shù),比如header中的登錄令牌Bearer Token的話,進(jìn)行針對(duì)性的寫法即可

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)

到此這篇關(guān)于Python使用seleniumwire接管Chrome查看控制臺(tái)中參數(shù)的文章就介紹到這了,更多相關(guān)Python seleniumwire控制臺(tái)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論