add a general 'generate_csrf_token()' function

This commit is contained in:
Mike Fährmann
2020-10-15 00:43:26 +02:00
parent 7a0ba370d1
commit 1b1cf01d0d
2 changed files with 7 additions and 4 deletions

View File

@@ -9,10 +9,8 @@
"""Extractors for https://twitter.com/"""
from .common import Extractor, Message
from .. import text, exception
from .. import text, util, exception
from ..cache import cache
import hashlib
import time
BASE_PATTERN = (
@@ -446,7 +444,7 @@ class TwitterAPI():
cookies = self.extractor.session.cookies
# CSRF
csrf = hashlib.md5(str(time.time()).encode()).hexdigest()
csrf = util.generate_csrf_token()
self.headers["x-csrf-token"] = csrf
cookies.set("ct0", csrf, domain=".twitter.com")