diff options
author | t.me/xtekky <98614666+xtekky@users.noreply.github.com> | 2023-04-22 11:57:45 +0200 |
---|---|---|
committer | t.me/xtekky <98614666+xtekky@users.noreply.github.com> | 2023-04-22 11:57:45 +0200 |
commit | 2b30701b2e491163bd923881920fa713ecde4718 (patch) | |
tree | 10539bc38b87f3ee4a225e992d8e2421931be704 /quora/mail.py | |
parent | Merge pull request #65 from VilotStar/main (diff) | |
download | gpt4free-2b30701b2e491163bd923881920fa713ecde4718.tar gpt4free-2b30701b2e491163bd923881920fa713ecde4718.tar.gz gpt4free-2b30701b2e491163bd923881920fa713ecde4718.tar.bz2 gpt4free-2b30701b2e491163bd923881920fa713ecde4718.tar.lz gpt4free-2b30701b2e491163bd923881920fa713ecde4718.tar.xz gpt4free-2b30701b2e491163bd923881920fa713ecde4718.tar.zst gpt4free-2b30701b2e491163bd923881920fa713ecde4718.zip |
Diffstat (limited to 'quora/mail.py')
-rw-r--r-- | quora/mail.py | 93 |
1 files changed, 60 insertions, 33 deletions
diff --git a/quora/mail.py b/quora/mail.py index 07f7093a..a830502e 100644 --- a/quora/mail.py +++ b/quora/mail.py @@ -1,39 +1,66 @@ -import html -import json -from tls_client import Session - -class Mail: - def __init__(self, proxies: str = None, timeout: int = 15, bearer_token: str or None = None) -> None: - self.session = Session(client_identifier='chrome110') - self.base_url = 'https://web2.temp-mail.org' - self.proxies = proxies - self.timeout = timeout - - self.session.headers['authorization'] = f'Bearer {bearer_token}' if bearer_token else None +from requests import Session +from time import sleep +from re import search, findall +from json import loads - def get_mail(self) -> str: - status: html = self.session.get(self.base_url).status_code - - try: - if status == 200: - data = self.session.post(f'{self.base_url}/mailbox').json() +class Emailnator: + def __init__(self) -> None: + self.client = Session() + self.client.get('https://www.emailnator.com/', timeout=6) + self.cookies = self.client.cookies.get_dict() - self.session.headers['authorization'] = f'Bearer {data["token"]}' - return data["token"], data["mailbox"] + self.client.headers = { + 'authority' : 'www.emailnator.com', + 'origin' : 'https://www.emailnator.com', + 'referer' : 'https://www.emailnator.com/', + 'user-agent' : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.0.0 Safari/537.36 Edg/101.0.1722.39', + 'x-xsrf-token' : self.client.cookies.get("XSRF-TOKEN")[:-3]+"=", + } - except Exception as e: - print(e) - return f'Email creation error. {e} | use proxies', False - - def fetch_inbox(self) -> json: - return self.session.get(f'{self.base_url}/messages').json() + self.email = None + + def get_mail(self): + response = self.client.post('https://www.emailnator.com/generate-email',json = { + 'email': [ + 'domain', + 'plusGmail', + 'dotGmail', + ] + }) + + self.email = loads(response.text)["email"][0] + return self.email - def get_message_content(self, message_id: str): - return self.session.get(f'{self.base_url}/messages/{message_id}').json()["bodyHtml"] + def get_message(self): + print("waiting for code...") + + while True: + sleep(2) + mail_token = self.client.post('https://www.emailnator.com/message-list', + json = {'email': self.email}) + + mail_token = loads(mail_token.text)["messageData"] + + if len(mail_token) == 2: + print(mail_token[1]["messageID"]) + break + + mail_context = self.client.post('https://www.emailnator.com/message-list', json = { + 'email' : self.email, + 'messageID': mail_token[1]["messageID"], + }) + + return mail_context.text + +# mail_client = Emailnator() +# mail_adress = mail_client.get_mail() + +# print(mail_adress) + +# mail_content = mail_client.get_message() + +# print(mail_content) -# if __name__ == '__main__': +# code = findall(r';">(\d{6,7})</div>', mail_content)[0] +# print(code) -# email_client = TempMail() -# token, email = email_client.get_mail() -# print(email) -# print(token)
\ No newline at end of file |