-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
42 lines (36 loc) · 1.53 KB
/
index.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
import requests
from zfunctions.f import *
# ir a buscar url de imagenes a servidor froxa
headers = {'User-Agent': 'Google'}
response = requests.get('https://intranet.froxa.net/aimagen/give_me_pictures_of_yesterday_and_today.php', headers=headers)
if response.status_code == 200:
data = response.json()
if data['res'] == 'ok':
x = data['last_day']
y = data['today']
# guardo la primera imagen localmente
respuesta = requests.get(x)
if respuesta.status_code == 200:
nombre_archivo = 'download/'+os.path.basename(x)
with open(nombre_archivo, 'wb') as archivo:
archivo.write(respuesta.content)
else:
print(f"Error x: {respuesta.status_code}")
# guardo la segunda imagen localmente
respuesta = requests.get(y)
if respuesta.status_code == 200:
nombre_archivo = 'download/'+os.path.basename(y)
with open(nombre_archivo, 'wb') as archivo:
archivo.write(respuesta.content)
else:
print(f"Error y: {respuesta.status_code}")
# envio correo con enlaces y archivos
send_email_with_attachments('[email protected]', '[email protected]', 'xlganerhawjkiiar', x, y)
else:
print(f'Error: {response.status_code}')
# elimino arhivos locales de mas de 11 dias
delete_old_files()
# elimino archivos en servidor froxa
res = requests.get('https://intranet.froxa.net/aimagen/delete_forder.php', headers=headers)
data = res.json()
print(data)