From dc91c1dd45a0827eb68c47a6e2eb00191a027072 Mon Sep 17 00:00:00 2001 From: Dor Segal Date: Thu, 18 Jul 2024 01:21:46 +0200 Subject: [PATCH] fix url emailinator (#14) * fix url emailinator * Update setup.py --- .../temp_mail/gmailnator/__init__.py | 47 ++++++++----- .../temp_mail/gmailnator/letter.py | 29 +++++--- setup.py | 66 +++++++++---------- 3 files changed, 85 insertions(+), 57 deletions(-) diff --git a/account_generator_helper/temp_mail/gmailnator/__init__.py b/account_generator_helper/temp_mail/gmailnator/__init__.py index 890e13c..224d753 100644 --- a/account_generator_helper/temp_mail/gmailnator/__init__.py +++ b/account_generator_helper/temp_mail/gmailnator/__init__.py @@ -5,24 +5,24 @@ from urllib.parse import unquote headers = { - 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', - 'content-type': 'application/json' + "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", + "content-type": "application/json", } class GmailNator(Mail): """ - Class for work with https://www.emailnator.com/ + Class for work with https://emailnator.com/ """ def __init__(self, proxy=None): super().__init__(proxy) - r = self._s.get('https://www.emailnator.com/') + r = self._s.get("https://emailnator.com/") if r.status_code == 403: raise CloudflareDetect() def __get_xsrf_token(self): - token = self._s.cookies.get('XSRF-TOKEN', '') + token = self._s.cookies.get("XSRF-TOKEN", "") if not token: raise CloudflareDetect() return unquote(token) @@ -39,12 +39,23 @@ def get_email_online(self, use_custom_domain=True, use_plus=True, use_point=True :param use_point: Generate email with "." in address. :return: Random email address. """ - data = ['domain', 'plusGmail', 'dotGmail'] - payload = json.dumps({'email': [i for i, k in zip(data, [use_custom_domain, use_plus, use_point]) if k]}) - r = self._s.post('https://www.emailnator.com/generate-email', - headers={**headers, 'x-xsrf-token': self.__get_xsrf_token()}, data=payload) + data = ["domain", "plusGmail", "dotGmail"] + payload = json.dumps( + { + "email": [ + i + for i, k in zip(data, [use_custom_domain, use_plus, use_point]) + if k + ] + } + ) + r = self._s.post( + "https://emailnator.com/generate-email", + headers={**headers, "x-xsrf-token": self.__get_xsrf_token()}, + data=payload, + ) if r.status_code == 200: - return self._set_email(r.json()['email'][0]) + return self._set_email(r.json()["email"][0]) raise ProblemWithGetEmail() def set_email(self, email): @@ -54,10 +65,16 @@ def set_email(self, email): return self._set_email(email) def get_inbox(self): - payload = json.dumps({'email': self._email}) - r = self._s.post('https://www.emailnator.com/message-list', - headers={**headers, 'x-xsrf-token': self.__get_xsrf_token()}, data=payload) + payload = json.dumps({"email": self._email}) + r = self._s.post( + "https://emailnator.com/message-list", + headers={**headers, "x-xsrf-token": self.__get_xsrf_token()}, + data=payload, + ) if r.status_code == 200: - return [Letter(self._email, _letter, self.__get_xsrf_token(), self._s) for _letter in r.json()['messageData'] if - 'ADS' not in _letter['messageID']] + return [ + Letter(self._email, _letter, self.__get_xsrf_token(), self._s) + for _letter in r.json()["messageData"] + if "ADS" not in _letter["messageID"] + ] return [] diff --git a/account_generator_helper/temp_mail/gmailnator/letter.py b/account_generator_helper/temp_mail/gmailnator/letter.py index 1918ee2..0ab7a18 100644 --- a/account_generator_helper/temp_mail/gmailnator/letter.py +++ b/account_generator_helper/temp_mail/gmailnator/letter.py @@ -5,8 +5,8 @@ header_regex = r'
From: <\/b>.*Subject: <\/b>[^<]*<\/b>
Time: <\/b>[^<]*<\/div><\/div>' headers = { - 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', - 'content-type': 'application/json' + "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", + "content-type": "application/json", } @@ -14,18 +14,29 @@ class Letter(letter.Letter): def __init__(self, to, content, token, session): self._token = token self._s = session - if '<' in content['from']: - name, from_email = re.findall(r'^(.*) <(.*)>$', content['from'])[0] + if "<" in content["from"]: + name, from_email = re.findall(r"^(.*) <(.*)>$", content["from"])[0] else: - name = from_email = content['from'] - super().__init__(to, name, from_email, content['subject'], datetime.fromtimestamp(0), content['messageID']) + name = from_email = content["from"] + super().__init__( + to, + name, + from_email, + content["subject"], + datetime.fromtimestamp(0), + content["messageID"], + ) @property def letter(self): if self._letter: return self._letter - payload = json.dumps({'email': self._email, 'messageID': self._letter_id}) - r = self._s.post('https://www.emailnator.com/message-list', data=payload, headers={**headers, 'x-xsrf-token': self._token}) + payload = json.dumps({"email": self._email, "messageID": self._letter_id}) + r = self._s.post( + "https://emailnator.com/message-list", + data=payload, + headers={**headers, "x-xsrf-token": self._token}, + ) if r.status_code == 200: - self._letter = re.sub(header_regex, '', r.text) + self._letter = re.sub(header_regex, "", r.text) return self._letter diff --git a/setup.py b/setup.py index 93275d0..ed7f1c2 100644 --- a/setup.py +++ b/setup.py @@ -3,45 +3,45 @@ this_directory = Path(__file__).parent -long_description = (this_directory / 'README.md').read_text() -required = (this_directory / 'requirements.txt').read_text().splitlines() +long_description = (this_directory / "README.md").read_text() +required = (this_directory / "requirements.txt").read_text().splitlines() setup( - name='account_generator_helper', - version='1.0.14', + name="account_generator_helper", + version="1.0.15", packages=find_packages(), classifiers=[ - 'Development Status :: 3 - Alpha', - 'License :: OSI Approved :: MIT License', - 'Environment :: Console', - 'Intended Audience :: Developers', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Topic :: Communications :: Email', - 'Topic :: Utilities', - 'Topic :: Internet :: Proxy Servers', + "Development Status :: 3 - Alpha", + "License :: OSI Approved :: MIT License", + "Environment :: Console", + "Intended Audience :: Developers", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Communications :: Email", + "Topic :: Utilities", + "Topic :: Internet :: Proxy Servers", ], project_urls={ - 'Source': 'https://github.com/Dionis1902/AccountGeneratorHelper/tree/main/account_generator_helper', - 'Examples': 'https://github.com/Dionis1902/AccountGeneratorHelper/tree/main/examples', - 'Tracker': 'https://github.com/Dionis1902/AccountGeneratorHelper/issues', + "Source": "https://github.com/Dionis1902/AccountGeneratorHelper/tree/main/account_generator_helper", + "Examples": "https://github.com/Dionis1902/AccountGeneratorHelper/tree/main/examples", + "Tracker": "https://github.com/Dionis1902/AccountGeneratorHelper/issues", }, - url='https://github.com/DioniS1902/AccountGeneratorHelper', - license='MIT', - author='Dionis1902', - author_email='den70007.ua@gmail.com', - description='This library is helpful when creating accounts, it has everything you need for this', + url="https://github.com/DioniS1902/AccountGeneratorHelper", + license="MIT", + author="Dionis1902", + author_email="den70007.ua@gmail.com", + description="This library is helpful when creating accounts, it has everything you need for this", long_description=long_description, - long_description_content_type='text/markdown', - python_requires='>=3', - keywords='python email captcha proxy pypi sms gmail temp-mail captcha-solving captcha-solver fake-data account-generator captcha-recognition ' - 'fake-data-generator free-proxy recive-sms gmailnator gmailnator-api poxies', - install_requires=required + long_description_content_type="text/markdown", + python_requires=">=3", + keywords="python email captcha proxy pypi sms gmail temp-mail captcha-solving captcha-solver fake-data account-generator captcha-recognition " + "fake-data-generator free-proxy recive-sms gmailnator gmailnator-api poxies", + install_requires=required, )