import undetected_chromedriver
import time
import random
from seleniumwire import webdriver
from selenium.webdriver.chrome.options import Options
from fake_useragent import UserAgent
def parseCookieFile(cookiefile):
cookies = {}
with open(cookiefile, 'r') as fp:
content = fp.read()
lines = content.strip().split('\n')
for line in lines:
if not line.startswith('#'):
fields = line.strip().split('\t')
if len(fields) >= 7:
name = fields[5]
value = fields[6]
cookies[name] = value
return cookies
a = parseCookieFile('s.txt')
if __name__ == '__main__':
options = undetected_chromedriver.ChromeOptions()
options.add_argument('--user-data-dir')
options.add_argument('--allow-running-insecure-content')
options.add_argument('--disable-web-security')
options.add_argument("--disable-gpu")
options.add_argument('--disable-dev-shm-usage')
options.add_argument("user-agent=Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0")
options.add_argument("--disable-blink-features=AutomationControlled")
browser = undetected_chromedriver.Chrome(options=options,
driver_executable_path=my_path)
browser.delete_all_cookies()
browser.get('https://www.google.com/')
browser.implicitly_wait(15)
time.sleep(10)
browser.get('https://accounts.google.com/v3/signin/identifier?continue=https%3A%2F%2Fwww.google.com%2F&ec=GAZAmgQ&hl=ru&ifkv=AVQVeyy2_AjsoEWxgealPJCDMF4_tYlRJ5ViuAoO6vYzn-W8gF63iAdSni_8MqneegEum1TR8UxflA&passive=true&flowName=GlifWebSignIn&flowEntry=ServiceLogin&dsh=S370086579%3A1697312770591432&theme=glif')
time.sleep(10)
for name, value in a.items():
browser.add_cookie({'name': name, 'value': value})
time.sleep(10)
browser.get('https://accounts.google.com/AccountChooser/signinchooser?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&flowName=GlifWebSignIn&flowEntry=AccountChooser&theme=glif')
time.sleep(10)
browser.get('https://mail.google.com/mail/u/0/')
time.sleep(10)
There are cookies in txt, I tried to add them to the cookies of the browser itself, and when I go to the authorization page of the first mail, I get the following error
The server cannot process the request due to syntax errors. Error 400
But at the same time, if I enter my username and password, everything works fine