Skip to content

Commit

Permalink
fix url emailinator (#14)
Browse files Browse the repository at this point in the history
* fix url emailinator

* Update setup.py
  • Loading branch information
dorsegal authored Jul 17, 2024
1 parent d33a616 commit dc91c1d
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 57 deletions.
47 changes: 32 additions & 15 deletions account_generator_helper/temp_mail/gmailnator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand All @@ -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 []
29 changes: 20 additions & 9 deletions account_generator_helper/temp_mail/gmailnator/letter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,38 @@

header_regex = r'<div id="subject-header"><b>From: <\/b>.*<br\/><b>Subject: <\/b>[^<]*<\/b><div><b>Time: <\/b>[^<]*<hr\s*\/><\/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",
}


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
66 changes: 33 additions & 33 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='[email protected]',
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="[email protected]",
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,
)

0 comments on commit dc91c1d

Please sign in to comment.