Ответы пользователя по тегу Яндекс
  • Как получить x-csrf-token yandex?

    @megashchik
    Есть такой запрос, но он не всегда подходит
    https://frontend.vh.yandex.ru/csrf_token
    А можно еще
    import requests
    from bs4 import BeautifulSoup
    
    s = requests.Session()
    resp = s.get("https://passport.yandex.ru/")
    soup = BeautifulSoup(resp.text, "html.parser")
    csrf = soup.find("input", {"name": "csrf_token"})["value"]
    print(csrf)


    Без парсинга html
    import requests
    import json
    
    s = requests.Session()
    csrf = json.loads(s.post('https://passport.yandex.ru/registration-validations/auth/accounts').text)["csrf"]
    Ответ написан
    Комментировать