-
Notifications
You must be signed in to change notification settings - Fork 0
/
prenotaDore.py
182 lines (167 loc) · 5.86 KB
/
prenotaDore.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/python
from bs4 import BeautifulSoup as bs
import requests
import random
from bs4 import BeautifulSoup
from urllib.parse import urljoin
import json
import imaplib
import email
from email.header import decode_header
import webbrowser
import os
import time
from datetime import date
import datetime
today = date.today()
nextWeek = today + datetime.timedelta( 7 )
username = ""
password = ""
payloadMattina = {
"email":username,
"date":str(nextWeek),
"start_time":"9:00",
"end_time":"14:00",
"note":None,
"user_firstname":None,
"user_lastname":None,
"user_phone":None,
"person_count":1}
payloadPomeriggio = {
"email":username,
"date":str(nextWeek),
"start_time":"14:00",
"end_time":"19:00",
"note":None,
"user_firstname":None,
"user_lastname":None,
"user_phone":None,
"person_count":1}
payloadSera = {
"email":username,
"date":str(nextWeek),
"start_time":"19:00",
"end_time":"23:55",
"note":None,
"user_firstname":None,
"user_lastname":None,
"user_phone":None,
"person_count":1}
user_agent_list = [
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1.1 Safari/605.1.15',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:77.0) Gecko/20100101 Firefox/77.0',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36']
url = 'https://httpbin.org/headers'
user_agent = random.choice(user_agent_list)
headers = {'User-Agent': user_agent}
link="https://reservation.affluences.com/api/reserve/50039"# per dore
#link="https://reservation.affluences.com/api/reserve/50825" #per rimini
r1 = requests.post(link, json=payloadMattina,timeout=5)
time.sleep(5)
#user_agent = random.choice(user_agent_list)
r1 = requests.post(link, json=payloadPomeriggio,timeout=5)
time.sleep(10)
r1 = requests.post(link, json=payloadSera,timeout=5)
time.sleep(10)
######################
###MAIL###########
######################
imap = imaplib.IMAP4_SSL("outlook.office365.com")
imap.login(username, password)
status, messages = imap.select("INBOX")
messaggi_1 = int(messages[0])
res, msg = imap.fetch(str(messaggi_1), "(RFC822)")
for response in msg:
if isinstance(response, tuple):
msg = email.message_from_bytes(response[1])
if msg.is_multipart():
for part in msg.walk():
try:
body_1 = part.get_payload(decode=True).decode()
except:
pass
messaggi_2 = int(messages[0])
res, msg = imap.fetch(str(messaggi_2-1), "(RFC822)")
for response in msg:
if isinstance(response, tuple):
msg = email.message_from_bytes(response[1])
if msg.is_multipart():
for part in msg.walk():
try:
body_2 = part.get_payload(decode=True).decode()
except:
pass
messaggi_3 = int(messages[0])
res, msg = imap.fetch(str(messaggi_2-2), "(RFC822)")
for response in msg:
if isinstance(response, tuple):
msg = email.message_from_bytes(response[1])
if msg.is_multipart():
for part in msg.walk():
try:
body_3 = part.get_payload(decode=True).decode()
except:
pass
imap.close()
imap.logout()
#####################
##confermo mattina###
####################
soup=(BeautifulSoup(body_1, 'html.parser'))
soup.encode('utf-8')
url=""
for link in soup.findAll('a'):
url=str(link)[len("<a href=\""):len("<a href=\"https://affluences.com/reservation/confirm?reservationToken=941f3dfb-c945-57da-9eed-cfcad868c02e")]
break
t=url[len("https://affluences.com/reservation/confirm?reservationToken="):]
l="https://reservation.affluences.com/api/reservations/"+t+"/confirmation"
headers = {
"authority": "reservation.affluences.com",
"method": "POST",
"path": "/api/reservations/"+t+"/confirmation",
"scheme": "https",
"accept": "application/json, text/plain, */*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "it",
"content-length": "2",
"content-type": "application/json",
"dnt": "1",
"origin": "https://affluences.com",
"referer": "https://affluences.com/",
"sec-ch-ua": "\"Chromium\";v=\"88\", \"Google Chrome\";v=\"88\", \";Not A Brand\";v=\"99\"",
"sec-ch-ua-mobile": "?0",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": user_agent
}
r1= requests.options(l, timeout=1)
r1 = requests.post(l,json={}, headers=headers,timeout=5)
########################
###CONFERMA POMERIGGIO###########
########################
soup=(BeautifulSoup(body_2, 'html.parser'))
soup.encode('utf-8')
url=""
for link in soup.findAll('a'):
url=str(link)[len("<a href=\""):len("<a href=\"https://affluences.com/reservation/confirm?reservationToken=941f3dfb-c945-57da-9eed-cfcad868c02e")]
break
t=url[len("https://affluences.com/reservation/confirm?reservationToken="):]
l="https://reservation.affluences.com/api/reservations/"+t+"/confirmation"
r1= requests.options(l, timeout=1)
r1 = requests.post(l,json={}, headers=headers,timeout=5)
########################
###CONFERMA SERA###########
########################
soup=(BeautifulSoup(body_3, 'html.parser'))
soup.encode('utf-8')
url=""
for link in soup.findAll('a'):
url=str(link)[len("<a href=\""):len("<a href=\"https://affluences.com/reservation/confirm?reservationToken=941f3dfb-c945-57da-9eed-cfcad868c02e")]
break
t=url[len("https://affluences.com/reservation/confirm?reservationToken="):]
l="https://reservation.affluences.com/api/reservations/"+t+"/confirmation"
r1= requests.options(l, timeout=1)
r1 = requests.post(l,json={}, headers=headers,timeout=5)