1
0
Fork 0
mirror of https://github.com/kemayo/leech synced 2026-02-07 15:21:36 +01:00

Fix xenforo login

This commit is contained in:
David Lynch 2024-05-14 22:04:44 -05:00
parent 7dc6543e44
commit ef9309eb66

View file

@ -3,6 +3,7 @@
import datetime
import re
import logging
import requests_cache
from bs4 import BeautifulSoup
from . import register, Site, SiteException, SiteSpecificOption, Section, Chapter
@ -60,13 +61,19 @@ class XenForo(Site):
return f'https://{self.domain}/{path}'
def login(self, login_details):
# Todo: handle non-https?
post = {
'login': login_details[0],
'password': login_details[1],
}
self.session.post(self.siteurl('login/login'), data=post)
logger.info("Logged in as %s", login_details[0])
with requests_cache.disabled():
login = self.session.get(self.siteurl('login/'))
soup = BeautifulSoup(login.text, 'html5lib')
post, action, method = self._form_data(soup.find(class_='p-body-content'))
post['login'] = login_details[0]
post['password'] = login_details[1]
# I feel the session *should* handle this cookies bit for me. But
# it doesn't. And I don't know why.
self.session.post(
self._join_url(login.url, action),
data=post, cookies=login.cookies
)
logger.info("Logged in as %s", login_details[0])
def extract(self, url):
soup = self._soup(url)