selenium.common.exceptions.InvalidCookieDomainException: Message: invalid cookie domain: Cookie 'domain' mismatch
  (Session info: chrome=97.0.4692.71)
Stacktrace:
Backtrace:
    Ordinal0 [0x009E6903+2517251]
    Ordinal0 [0x0097F8E1+2095329]
    Ordinal0 [0x00882848+1058888]
    Ordinal0 [0x008E3FD5+1458133]
    Ordinal0 [0x008C64D3+1336531]
    Ordinal0 [0x008D5BBF+1399743]
    Ordinal0 [0x008C639B+1336219]
    Ordinal0 [0x008A27A7+1189799]
    Ordinal0 [0x008A3609+1193481]
    GetHandleVerifier [0x00B75904+1577972]
    GetHandleVerifier [0x00C20B97+2279047]
    GetHandleVerifier [0x00A76D09+534521]
    GetHandleVerifier [0x00A75DB9+530601]
    Ordinal0 [0x00984FF9+2117625]
    Ordinal0 [0x009898A8+2136232]
    Ordinal0 [0x009899E2+2136546]
    Ordinal0 [0x00993541+2176321]
    BaseThreadInitThunk [0x75EFFA29+25]
    RtlGetAppContainerNamedObjectPath [0x77D67A9E+286]
    RtlGetAppContainerNamedObjectPath [0x77D67A6E+238]


Process finished with exit code 1

 

前几天程序跑起来还是正常的,现在直接报错,出现了cookies的这个问题

我尝试了用这个函数来解决读取cookies的问题,但是没有用还是老问题

def getPureDomainCookies(cookies):
    domain2cookie={}  #做一个域到cookie的映射
    for cookie in cookies:
        domain=cookie['domain']
        if domain in domain2cookie:
            domain2cookie[domain].append(cookie)
        else:
            domain2cookie[domain]=[]
    maxCnt=0
    ansDomain=''
    for domain in domain2cookie.keys():
        cnt=len(domain2cookie[domain])
        if cnt > maxCnt:
            maxCnt=cnt
            ansDomain=domain
    ansCookies=domain2cookie[ansDomain]
    return ansCookies