-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathutilities.py
170 lines (149 loc) · 6.42 KB
/
utilities.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
import requests
import os
import csv, smtplib, ssl
from email.mime.text import MIMEText
import shutil
from datetime import datetime, timedelta
def getlist2013(page,settore):
tutti=[]
response=requests.get(page)
text=response.text
while ' ' in text:
text = text.replace(' ','')
text = text.replace('<td>','')
text = text.replace('</td>','')
text = text.replace('</b>','')
text = text.replace('<tdstyle="padding-left:5px;">','')
entries=text.split()
for i in range (len(entries)):
if ('Dal' in entries[i]):
if 'text-align' in entries[i-5]:
x = {
"Cognome": entries[i-9].replace('<bstyle="text-align:center;display:block">',''),
"Nome": entries[i-8].replace('<bstyle="text-align:center;display:block">',''),
"Esito": entries[i-6].replace('<bstyle="text-align:center;display:block">',''),
"Data": entries[i].replace('Dal',''),
"Settore": settore
}
else:
x = {
"Cognome": entries[i-6].replace('<bstyle="text-align:center;display:block">',''),
"Nome": entries[i-5].replace('<bstyle="text-align:center;display:block">',''),
"Esito": entries[i-3].replace('<bstyle="text-align:center;display:block">',''),
"Data": entries[i].replace('Dal',''),
"Settore": settore
}
tutti.append(x)
return tutti
def getlist(page,settore):
tutti=[]
response=requests.get(page)
text=response.text
while ' ' in text:
text = text.replace(' ','')
text = text.replace('<td>','')
text = text.replace('</td>','')
text = text.replace('</b>','')
text = text.replace('<tdstyle="padding-left:5px;">','')
entries=text.split()
for i in range (len(entries)):
if ('Dal' in entries[i]):
x = {
"Cognome": entries[i-4].replace('<bstyle="text-align:center;display:block">',''),
"Nome": entries[i-3].replace('<bstyle="text-align:center;display:block">',''),
"Esito": entries[i-1].replace('<bstyle="text-align:center;display:block">',''),
"Data": entries[i].replace('Dal',''),
"Settore": settore
}
tutti.append(x)
return tutti
def getfulllist(page,settore):
tutti=[]
response=requests.get(page)
text=response.text
while ' ' in text:
text = text.replace(' ','')
text = text.replace('<td>','')
text = text.replace('</td>','')
text = text.replace('</b>','')
text = text.replace('<tdstyle="padding-left:5px;">','')
entries=text.split()
for i in range (len(entries)):
if ('pubblicazioni' in entries[i]):
x = {
"Cognome": entries[i-3].replace('<bstyle="text-align:center;display:block">',''),
"Nome": entries[i-2].replace('<bstyle="text-align:center;display:block">',''),
"Esito": entries[i+14].replace('<bstyle="text-align:center;display:block">',''),
"Data": None,
"Settore": settore
}
if x["Esito"]=="Si":
x["Data"]= entries[i+15].replace('Dal','')
tutti.append(x)
return tutti
def getalllist(s1,s2,f):
pages=[]
pages.append("https://abilitazione.cineca.it/ministero.php/public/esitoAbilitati/settore/"+s1+"%252F"+s2+"/fascia/"+f)
pages.append("https://asn.cineca.it/ministero.php/public/esitoAbilitati/settore/"+s1+"%252F"+s2+"/fascia/"+f)
pages.append("https://asn16.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/1")
pages.append("https://asn16.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/2")
pages.append("https://asn16.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/3")
pages.append("https://asn16.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/4")
pages.append("https://asn16.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/5")
pages.append("https://asn18.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/1")
pages.append("https://asn18.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/2")
pages.append("https://asn18.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/3")
pages.append("https://asn18.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/4")
pages.append("https://asn18.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/5")
pages.append("https://asn18.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/6")
pages.append("https://asn21.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/1")
pages.append("https://asn21.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/2")
pages.append("https://asn21.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/3")
pages.append("https://asn21.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/4")
pages.append("https://asn21.cineca.it/pubblico/miur/esito-abilitato/"+s1+"%252F"+s2+"/"+f+"/5")
ab=[]
for i in range(len(pages)):
page=pages[i]
if (i==1):
ab=ab+(getlist2013(page,s1+s2))
else:
ab=ab+(getlist(page,s1+s2))
ab.sort(key=lambda x: (x["Cognome"], x["Nome"]))
return ab
def evstats(list):
c=0
for item in list:
if (item["Esito"]=="Si"):
c+=1
if len(list)>0:
sup=c/len(list)
else:
sup=None
return sup
def comparelists(list1,list2):
commonlist=[]
for item1 in list1:
for item2 in list2:
if item1["Cognome"]==item2["Cognome"] and item1["Nome"]==item2["Nome"]:
x = {
"Cognome": item1["Cognome"],
"Nome": item1["Nome"],
"Settore1": item1["Settore"],
"Data1": item1["Data"],
"Settore2": item2["Settore"],
"Data2": item2["Data"],
}
commonlist.append(x)
return commonlist
def readsecs(filename):
f=open(filename,'r')
lines=f.readlines()
settori=[]
for line in lines:
x={
"area": line.split()[0],
"settore": line.split()[1]
}
print(x)
settori.append(x)
return settori