rename 'generate_csrf_token()' to just 'generate_token()'

and add a 'size' argument
This commit is contained in:
Mike Fährmann
2021-01-11 22:12:40 +01:00
parent f277e48c77
commit 780b6adb91
7 changed files with 28 additions and 11 deletions

View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright 2018-2020 Leonardo Taccari
# Copyright 2018-2020 Mike Fährmann
# Copyright 2018-2021 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -35,7 +35,7 @@ class InstagramExtractor(Extractor):
Extractor.__init__(self, match)
self.item = match.group(1)
self.www_claim = "0"
self.csrf_token = util.generate_csrf_token()
self.csrf_token = util.generate_token()
self._find_tags = re.compile(r"#\w+").findall
self._cursor = None

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2020 Mike Fährmann
# Copyright 2016-2021 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -305,7 +305,7 @@ class PinterestAPI():
def __init__(self, extractor):
self.extractor = extractor
csrf_token = util.generate_csrf_token()
csrf_token = util.generate_token()
self.headers = self.HEADERS.copy()
self.headers["X-CSRFToken"] = csrf_token
self.cookies = {"csrftoken": csrf_token}

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2020 Mike Fährmann
# Copyright 2016-2021 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@@ -239,7 +239,7 @@ class TwitterExtractor(Extractor):
def _login_impl(self, username, password):
self.log.info("Logging in as %s", username)
token = util.generate_csrf_token()
token = util.generate_token()
self.session.cookies.clear()
self.request(self.root + "/login")
@@ -509,7 +509,7 @@ class TwitterAPI():
# CSRF
csrf_token = cookies.get("ct0", domain=cookiedomain)
if not csrf_token:
csrf_token = util.generate_csrf_token()
csrf_token = util.generate_token()
cookies.set("ct0", csrf_token, domain=cookiedomain)
self.headers["x-csrf-token"] = csrf_token