Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Fix endless forum login (#659) #711

Merged
merged 1 commit into from
Dec 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cyberdrop_dl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.0.86"
__version__ = "5.0.87"
8 changes: 4 additions & 4 deletions cyberdrop_dl/scraper/crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@ async def forum_login(self, login_url: URL, session_cookie: str, username: str,

while True:
try:
attempt += 1
if attempt == 5:
raise FailedLoginFailure(status=403, message="Failed to login after 5 attempts")

assert login_url.host is not None

text = await self.client.get_text(self.domain, login_url)
if "You are already logged in" in text:
if '<span class="p-navgroup-user-linkText">' in text:
self.logged_in = True
return

Expand All @@ -137,12 +138,11 @@ async def forum_login(self, login_url: URL, session_cookie: str, username: str,
await self.client.post_data(self.domain, login_url / "login", data=data, req_resp=False)
await asyncio.sleep(wait_time)
text = await self.client.get_text(self.domain, login_url)
if "You are already logged in" not in text:
if '<span class="p-navgroup-user-linkText">' not in text:
continue

self.logged_in = True
break
except asyncio.exceptions.TimeoutError:
attempt += 1
continue

"""~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"""
Expand Down
Loading