This commit is contained in:
parent
d6396e4050
commit
8b5449b1fd
15 changed files with 663 additions and 302 deletions
|
|
@ -2,7 +2,7 @@ import asyncio
|
|||
import logging
|
||||
import re
|
||||
|
||||
from playwright.async_api import BrowserContext, Page
|
||||
from playwright.async_api import BrowserContext, Error as PlaywrightError, Page
|
||||
|
||||
from .base import BaseProvider
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ class TempMailOrgProvider(BaseProvider):
|
|||
value,
|
||||
)
|
||||
return value
|
||||
except Exception:
|
||||
except PlaywrightError:
|
||||
continue
|
||||
|
||||
try:
|
||||
|
|
@ -53,8 +53,8 @@ class TempMailOrgProvider(BaseProvider):
|
|||
if found:
|
||||
logger.info("[temp-mail.org] email found by body scan: %s", found)
|
||||
return found
|
||||
except Exception:
|
||||
pass
|
||||
except PlaywrightError:
|
||||
logger.debug("Failed to scan body text for email")
|
||||
|
||||
await asyncio.sleep(1)
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ class TempMailOrgProvider(BaseProvider):
|
|||
try:
|
||||
count = await items.count()
|
||||
logger.info("[temp-mail.org] inbox items: %s", count)
|
||||
except Exception:
|
||||
except PlaywrightError:
|
||||
count = 0
|
||||
|
||||
if count > 0:
|
||||
|
|
@ -87,30 +87,30 @@ class TempMailOrgProvider(BaseProvider):
|
|||
continue
|
||||
text = (await item.inner_text()).strip().replace("\n", " ")
|
||||
logger.info("[temp-mail.org] item[%s]: %s", idx, text[:160])
|
||||
except Exception:
|
||||
except PlaywrightError:
|
||||
continue
|
||||
if text:
|
||||
try:
|
||||
await item.click()
|
||||
logger.info("[temp-mail.org] opened item[%s]", idx)
|
||||
except Exception:
|
||||
pass
|
||||
except PlaywrightError:
|
||||
logger.debug("Failed to open inbox item[%s]", idx)
|
||||
|
||||
message_text = text
|
||||
try:
|
||||
content = await page.content()
|
||||
if content and "Your ChatGPT code is" in content:
|
||||
message_text = content
|
||||
except Exception:
|
||||
pass
|
||||
except PlaywrightError:
|
||||
logger.debug("Failed to read opened message content")
|
||||
|
||||
try:
|
||||
await page.go_back(
|
||||
wait_until="domcontentloaded", timeout=5000
|
||||
)
|
||||
logger.info("[temp-mail.org] returned back to inbox")
|
||||
except Exception:
|
||||
pass
|
||||
except PlaywrightError:
|
||||
logger.debug("Failed to return back to inbox")
|
||||
|
||||
return message_text
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue