-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathemail_api.py
More file actions
51 lines (40 loc) · 1.32 KB
/
email_api.py
File metadata and controls
51 lines (40 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import time
import random
import requests
headers = {
'X-API-Key': 'api_key',
'Content-Type': 'application/json'
}
def get_email():
while True:
try:
payload = {
"domain": random.choice(['dr.com', 'asia.com', 'mail.com']),
"site": "instagram.com"
}
response = requests.post(
"https://api.kopechka.com/api/v1/orders", headers=headers, json=payload
).json()
try:
data = response['data']
order_id = data['orderId']
email = data['email']
return email, order_id
except:
print(f"[!] Mail bekleniyor.. {response}")
except Exception as e:
print(e)
time.sleep(5)
def get_code(order_id: str):
try:
for _ in range(10):
response = requests.get(f"https://api.kopechka.com/api/v1/orders/{order_id}/messages", headers=headers).json()
messages = response['messages']
if len(messages) > 0:
title = messages[0]['title'].split(' ')[2]
return title
time.sleep(3)
except Exception as e:
print(e)
def cancel_mail(order_id: str):
requests.delete(f'https://api.kopechka.com/api/v1/orders/{order_id}', headers=headers)