[xenforo] improve error message extraction (#8919)
This commit is contained in:
@@ -178,7 +178,8 @@ class XenforoExtractor(BaseExtractor):
|
|||||||
|
|
||||||
if not response.history:
|
if not response.history:
|
||||||
err = self._extract_error(response.text)
|
err = self._extract_error(response.text)
|
||||||
raise exception.AuthenticationError(f'"{err}"')
|
err = f'"{err}"' if err else None
|
||||||
|
raise exception.AuthenticationError(err)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
cookie.name: cookie.value
|
cookie.name: cookie.value
|
||||||
@@ -237,8 +238,9 @@ class XenforoExtractor(BaseExtractor):
|
|||||||
page = self.request_page(url).text
|
page = self.request_page(url).text
|
||||||
|
|
||||||
def _extract_error(self, html):
|
def _extract_error(self, html):
|
||||||
return text.unescape(text.extr(
|
if msg := (text.extr(html, "blockMessage--error", "</") or
|
||||||
html, "blockMessage--error", "</").rpartition(">")[2].strip())
|
text.extr(html, '"blockMessage"', "</div>")):
|
||||||
|
return text.unescape(msg[msg.find(">")+1:].strip())
|
||||||
|
|
||||||
def _parse_post(self, html):
|
def _parse_post(self, html):
|
||||||
extr = text.extract_from(html)
|
extr = text.extract_from(html)
|
||||||
|
|||||||
Reference in New Issue
Block a user