[8chan] automatically determine TOS cookie name (#6318)
This commit is contained in:
@@ -27,12 +27,22 @@ class _8chanExtractor(Extractor):
|
|||||||
Extractor.__init__(self, match)
|
Extractor.__init__(self, match)
|
||||||
|
|
||||||
def _init(self):
|
def _init(self):
|
||||||
now = util.datetime_utcnow()
|
tos = self.cookies_tos_name()
|
||||||
domain = self.root.rpartition("/")[2]
|
self.cookies.set(tos, "1", domain=self.root[8:])
|
||||||
self.cookies.set(
|
|
||||||
now.strftime("TOS%Y%m%d"), "1", domain=domain)
|
@memcache()
|
||||||
self.cookies.set(
|
def cookies_tos_name(self):
|
||||||
(now - timedelta(1)).strftime("TOS%Y%m%d"), "1", domain=domain)
|
url = self.root + "/.static/pages/confirmed.html"
|
||||||
|
headers = {"Referer": self.root + "/.static/pages/disclaimer.html"}
|
||||||
|
response = self.request(url, headers=headers, allow_redirects=False)
|
||||||
|
|
||||||
|
for cookie in response.cookies:
|
||||||
|
if cookie.name.lower().startswith("tos"):
|
||||||
|
self.log.debug("TOS cookie name: %s", cookie.name)
|
||||||
|
return cookie.name
|
||||||
|
|
||||||
|
self.log.error("Unable to determin TOS cookie name")
|
||||||
|
return "TOS20241009"
|
||||||
|
|
||||||
@memcache()
|
@memcache()
|
||||||
def cookies_prepare(self):
|
def cookies_prepare(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user