0

У меня есть cookie формата:

sfwefwe=0d6e941b3815079247b9069e3111bf05; xf_session=dabb9d85f436511c910c1205b22392c4; _ga=GA1.1.195811485.1653158493; xf_is_not_mobile=1; _ym_uid=1653158493674995086; _ym_d=1653158493; _ym_isad=1; G_ENABLED_IDPS=google; _ga_J7RS527GFK=GS1.1.1653158492.1.1.1653161341.0

Как я могу конвертировать их в JSON формат используя Python? Вообще мне нужно загрузить эти куки в selenium webdriver. Буду вам очень благодарен если поможете.

1
  • Hello, welcome to Stack Overflow. This is the site of the Russian-speaking SO community, please translate your question into Russian.
    – Simon
    21 мая 2022 в 20:17

1 ответ 1

0
>>> cookies=map(lambda x: x.split('='), 'sfwefwe=0d6e941b3815079247b9069e3111bf05; xf_session=dabb9d85f436511c910c1205b22392c4; _ga=GA1.1.195811485.1653158493; xf_is_not_mobile=1; _ym_uid=1653158493674995086; _ym_d=1653158493; _ym_isad=1; G_ENABLED_IDPS=google; _ga_J7RS527GFK=GS1.1.1653158492.1.1.1653161341.0'.split('; '))
>>> for k, v in cookies: driver.add_cookie({'name': k, 'value': v})

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.