Merge pull request #29 from editor-syntax/patch-1
Browse files- quora/mail.py +16 -40
quora/mail.py
CHANGED
@@ -7,56 +7,32 @@ class Mail:
|
|
7 |
self.client = Session()
|
8 |
self.client.proxies = None #proxies
|
9 |
self.client.headers = {
|
10 |
-
"host": "api.mail.tm",
|
11 |
-
"connection": "keep-alive",
|
12 |
-
"sec-ch-ua": "\"Google Chrome\";v=\"111\", \"Not(A:Brand\";v=\"8\", \"Chromium\";v=\"111\"",
|
13 |
-
"accept": "application/json, text/plain, */*",
|
14 |
-
"content-type": "application/json",
|
15 |
-
"sec-ch-ua-mobile": "?0",
|
16 |
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36",
|
17 |
-
"
|
18 |
-
"
|
19 |
-
"sec-fetch-site": "same-site",
|
20 |
-
"sec-fetch-mode": "cors",
|
21 |
-
"sec-fetch-dest": "empty",
|
22 |
-
"referer": "https://mail.tm/",
|
23 |
-
"accept-encoding": "gzip, deflate, br",
|
24 |
-
"accept-language": "en-GB,en-US;q=0.9,en;q=0.8"
|
25 |
}
|
26 |
|
|
|
|
|
|
|
|
|
27 |
def get_mail(self) -> str:
|
28 |
token = ''.join(choices(ascii_letters, k=10)).lower()
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
if init.status_code == 201:
|
36 |
-
resp = self.client.post("https://api.mail.tm/token", json = {
|
37 |
-
**init.json(),
|
38 |
-
"password": token
|
39 |
-
})
|
40 |
-
|
41 |
-
self.client.headers['authorization'] = 'Bearer ' + resp.json()['token']
|
42 |
-
|
43 |
-
return f"{token}@bugfoo.com"
|
44 |
-
|
45 |
-
else:
|
46 |
-
raise Exception("Failed to create email")
|
47 |
-
|
48 |
def fetch_inbox(self):
|
49 |
-
return self.client.get(f"https://api.
|
50 |
|
51 |
def get_message(self, message_id: str):
|
52 |
-
return self.client.get(f"https://api.
|
53 |
|
54 |
def get_message_content(self, message_id: str):
|
55 |
-
return self.get_message(message_id)["
|
56 |
-
|
57 |
|
58 |
# if __name__ == "__main__":
|
59 |
# client = Mail()
|
60 |
-
#
|
61 |
-
|
62 |
-
|
|
|
7 |
self.client = Session()
|
8 |
self.client.proxies = None #proxies
|
9 |
self.client.headers = {
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36",
|
11 |
+
"Accept": "application/json",
|
12 |
+
"Content-Type": "application/json"
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
}
|
14 |
|
15 |
+
self.domain = "guerrillamail.com"
|
16 |
+
|
17 |
+
self.sid_token = self.client.get("https://api.guerrillamail.com/ajax.php?f=get_email_address").json()['sid_token']
|
18 |
+
|
19 |
def get_mail(self) -> str:
|
20 |
token = ''.join(choices(ascii_letters, k=10)).lower()
|
21 |
+
|
22 |
+
email_id = f"{token}@{self.domain}"
|
23 |
+
self.client.get(f"https://api.guerrillamail.com/ajax.php?f=set_email_user&email_user={token}&sid_token={self.sid_token}")
|
24 |
+
|
25 |
+
return email_id
|
26 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
def fetch_inbox(self):
|
28 |
+
return self.client.get(f"https://api.guerrillamail.com/ajax.php?f=get_emails&sid_token={self.sid_token}").json()
|
29 |
|
30 |
def get_message(self, message_id: str):
|
31 |
+
return self.client.get(f"https://api.guerrillamail.com/ajax.php?f=fetch_email&email_id={message_id}&sid_token={self.sid_token}").json()
|
32 |
|
33 |
def get_message_content(self, message_id: str):
|
34 |
+
return self.get_message(message_id)["mail_body"]
|
|
|
35 |
|
36 |
# if __name__ == "__main__":
|
37 |
# client = Mail()
|
38 |
+
# client.get_mail()
|
|
|
|