【发布时间】:2021-04-02 13:57:36
【问题描述】:
我的目标是使用请求标头从请求标头中获取 cookie。
我尝试过使用 request、selenium 和 seleniumwire,但我从它们得到的结果与我在浏览器(chrome)中找到的结果不同。
我试过的代码:
from seleniumwire import webdriver
import pickle, time
print("Start\n")
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('window-size=414x736')
options.add_argument('--disable-gpu')
options.add_argument('--hide-scrollbars')
options.add_argument('blink-settings=imagesEnabled=false')
options.add_argument('--headless')
options.add_argument('--enable-file-cookies')
## Get the URL
browser = webdriver.Chrome(executable_path='/usr/bin/chromedriver', options=options)
browser.get("https://www.xxxxxxx.com/xxxxxx")
time.sleep(5)
print(browser.get_cookies())
browser.quit()
我也试过在python中使用requests库,结果和selenium一样。
【问题讨论】:
-
代码产生的结果是什么?
标签: python selenium cookies python-requests