我正在使用python和selenium创建一个应用程序,我想在登录页面后从请求标头中获取授权令牌。
from selenium import Chrome
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
# For using sleep function because selenium
# works only when the all the elemets of the
# page is loaded.
import time
options = webdriver.ChromeOptions()
if not (showUI):
options.add_argument('headless')
options.add_argument('window-size=1920x1080')
options.add_argument("disable-gpu")
options.add_argument("--log-level=3")
options.add_argument("'verify_ssl': False")
#Path to your chrome profile
options.add_argument("user-data-dir="+chromeProfilePath)
browser = Chrome()
url = 'https://example.com'
browser.get(url)
user = browser.find_element_by_xpath('//*[@id="Username"]')
# Enter User Name
user.send_keys('USER')
password = browser.find_element_by_xpath('//*[@id="Password"]')
password.send_keys('PASSWORD')
password.send_keys(Keys.RETURN)
这部分代码之后,我登录了该站点。现在我需要用于发送请求的授权令牌。如何获取请求标头?