This repository has been archived by the owner on Dec 31, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
burger.py
110 lines (89 loc) · 2.18 KB
/
burger.py
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import requests
import uuid
from random import choice
BASE_URL = "https://www.appburgerking.cl"
HEADERS = {
'Origin': "https://www.appburgerking.cl",
'X-Requested-With': "XMLHttpRequest",
'Referer': "https://www.appburgerking.cl/",
}
NAMES = [
"Hugo",
"Sebastian",
"Victor",
"Santiago",
"Jose",
"Alex",
"Andres",
"Rodrigo",
"Felipe",
"Pablo",
"Cristian",
"Michael",
"Daniel",
"David",
"Eduardo"
]
LAST_NAMES = [
"Castañeda",
"Rojas",
"Urrutia",
"Ruiz",
"Bello",
"Santander",
"Salazar",
"Palacio",
"Soto",
"Cortes",
"Tapia",
"Perez",
"Pavez",
"Romero",
"Castro",
"Zambrano"
]
def register(email, password):
path = "/auth/register"
payload = {
"firstName": choice(NAMES),
"gender": "male",
"lastName": choice(LAST_NAMES),
"birthday-d": 1,
"birthday-m": 1,
"birthday-y": 1985,
"birthday": "1985-01-01",
"email": email,
"pass": password,
}
response = requests.post(BASE_URL + path, data=payload, headers=HEADERS).json()
return response["status"] == "ok"
def login(email, password):
path = "/auth/login"
payload = {
"email": email,
"pass": password
}
response = requests.post(BASE_URL + path, data=payload, headers=HEADERS).json()
if response["status"] != "ok":
return None
return response["payload"]["user"]["id"]
def activate_coupon(uid, cid):
path = "/coupon/activation"
payload = {
"couponId": cid,
"userId": uid,
"skey": str(uuid.uuid4())
}
response = requests.post(BASE_URL + path, data=payload, headers=HEADERS).json()
if response["status"] != "ok":
return None
return response["payload"]["activationId"]
def get_coupon_qr(aid):
path = "/coupon/qr/{}/json".format(aid)
response = requests.get(BASE_URL + path, headers=HEADERS).json()
if response["status"] != "ok":
return None
return response["payload"]["qrcode"]
def get_coupon_image(aid):
path = "/coupon/qr/{}".format(aid)
return requests.get(BASE_URL + path, headers=HEADERS, stream=True).raw