我正在制作一个Python3-脚本与Selenium4和壁虎网络驱动程序。我正在使用cookies = driver.get_cookies()在登录站点后捕获Cookie。问题是如何使用Requests模块在GET请求中从Selify获得Cookie。换句话说,我们如何才能用Selence捕获Cookie并在请求中使用这些Cookie?我尝试了this问题中的建议答案,但它不正确,而且这个问题已经一年多了,没有其他任何答案。
cookies = driver.get_cookies()
jv4diomz1#
尝试这样做:
cookies = driver.get_cookies() requests_cookies = {} for c in cookies: requests_cookies[c['name']] = c['value'] response = requests.get('http://some-host...', cookies=requests_cookies)
参考:
https://medium.com/geekculture/how-to-share-cookies-between-selenium-and-requests-in-python-d36c3c8768b
1条答案
按热度按时间jv4diomz1#
尝试这样做:
参考:
https://medium.com/geekculture/how-to-share-cookies-between-selenium-and-requests-in-python-d36c3c8768b