Spaces:
Runtime error
Runtime error
allenchienxxx
commited on
Commit
·
d815766
1
Parent(s):
6d3e00d
Update modules.py
Browse files- modules.py +11 -11
modules.py
CHANGED
@@ -14,7 +14,7 @@ def get_text_from_html(html_content):
|
|
14 |
return all_text
|
15 |
# get text content type from email
|
16 |
def get_text(file):
|
17 |
-
message = email.message_from_bytes(file
|
18 |
text_content = ""
|
19 |
for part in message.walk():
|
20 |
if part.get_content_type() == 'text/plain':
|
@@ -25,7 +25,7 @@ def get_text(file):
|
|
25 |
return get_text_from_html(get_html_general(file));
|
26 |
|
27 |
def get_email_html(file):
|
28 |
-
content = email.message_from_bytes(file
|
29 |
html_content = ""
|
30 |
for part in content.walk():
|
31 |
if part.get_content_type() == 'text/html':
|
@@ -93,7 +93,7 @@ def check_popWindow(file):
|
|
93 |
return False
|
94 |
|
95 |
def check_spf(file):
|
96 |
-
message = email.message_from_bytes(file
|
97 |
received_spf_header = message.get('Received-SPF')
|
98 |
if received_spf_header == None:
|
99 |
return 0
|
@@ -110,7 +110,7 @@ def check_spf(file):
|
|
110 |
else:
|
111 |
return 0
|
112 |
def check_dkim(file):
|
113 |
-
message = email.message_from_bytes(file
|
114 |
auth = message.get('Authentication-Results')
|
115 |
if auth == None:
|
116 |
return 0
|
@@ -122,7 +122,7 @@ def check_dkim(file):
|
|
122 |
else:
|
123 |
return 0
|
124 |
def check_dmarc(file):
|
125 |
-
message = email.message_from_bytes(file
|
126 |
auth = message.get('Authentication-Results')
|
127 |
if auth == None:
|
128 |
return 0
|
@@ -134,7 +134,7 @@ def check_dmarc(file):
|
|
134 |
else:
|
135 |
return 0
|
136 |
def check_deliver_receiver(file):
|
137 |
-
message = email.message_from_bytes(file
|
138 |
deliver = message.get('Delivered-To')
|
139 |
# print(deliver)
|
140 |
receiver = message.get('To')
|
@@ -144,7 +144,7 @@ def check_deliver_receiver(file):
|
|
144 |
else:
|
145 |
return 0
|
146 |
def check_encript(file):
|
147 |
-
message = email.message_from_bytes(file
|
148 |
received_headers = message.get_all('Received')
|
149 |
# print(received_headers)
|
150 |
version_string = 'version'
|
@@ -178,7 +178,7 @@ def get_urls_from_html(html_content):
|
|
178 |
urls += [href]
|
179 |
return urls
|
180 |
def get_text(file):
|
181 |
-
message = email.message_from_bytes(file
|
182 |
text_content = ""
|
183 |
for part in message.walk():
|
184 |
if part.get_content_type() == 'text/plain':
|
@@ -231,7 +231,7 @@ def get_num_FunctionWords(file):
|
|
231 |
|
232 |
|
233 |
def get_email_html(file):
|
234 |
-
content = email.message_from_bytes(file
|
235 |
html_content = ""
|
236 |
for part in content.walk():
|
237 |
if part.get_content_type() == 'text/html':
|
@@ -249,7 +249,7 @@ def get_num_sbj(file):
|
|
249 |
count = len(get_subject(file).split())
|
250 |
return count
|
251 |
def get_subject(file):
|
252 |
-
message = email.message_from_bytes(file
|
253 |
headers = message.items()
|
254 |
# Print the headers
|
255 |
subject = ""
|
@@ -265,7 +265,7 @@ def get_subject(file):
|
|
265 |
|
266 |
|
267 |
def get_sender(file):
|
268 |
-
message = email.message_from_bytes(file
|
269 |
headers = message.items()
|
270 |
# Print the headers
|
271 |
sender = ""
|
|
|
14 |
return all_text
|
15 |
# get text content type from email
|
16 |
def get_text(file):
|
17 |
+
message = email.message_from_bytes(file)
|
18 |
text_content = ""
|
19 |
for part in message.walk():
|
20 |
if part.get_content_type() == 'text/plain':
|
|
|
25 |
return get_text_from_html(get_html_general(file));
|
26 |
|
27 |
def get_email_html(file):
|
28 |
+
content = email.message_from_bytes(file)
|
29 |
html_content = ""
|
30 |
for part in content.walk():
|
31 |
if part.get_content_type() == 'text/html':
|
|
|
93 |
return False
|
94 |
|
95 |
def check_spf(file):
|
96 |
+
message = email.message_from_bytes(file)
|
97 |
received_spf_header = message.get('Received-SPF')
|
98 |
if received_spf_header == None:
|
99 |
return 0
|
|
|
110 |
else:
|
111 |
return 0
|
112 |
def check_dkim(file):
|
113 |
+
message = email.message_from_bytes(file)
|
114 |
auth = message.get('Authentication-Results')
|
115 |
if auth == None:
|
116 |
return 0
|
|
|
122 |
else:
|
123 |
return 0
|
124 |
def check_dmarc(file):
|
125 |
+
message = email.message_from_bytes(file)
|
126 |
auth = message.get('Authentication-Results')
|
127 |
if auth == None:
|
128 |
return 0
|
|
|
134 |
else:
|
135 |
return 0
|
136 |
def check_deliver_receiver(file):
|
137 |
+
message = email.message_from_bytes(file)
|
138 |
deliver = message.get('Delivered-To')
|
139 |
# print(deliver)
|
140 |
receiver = message.get('To')
|
|
|
144 |
else:
|
145 |
return 0
|
146 |
def check_encript(file):
|
147 |
+
message = email.message_from_bytes(file)
|
148 |
received_headers = message.get_all('Received')
|
149 |
# print(received_headers)
|
150 |
version_string = 'version'
|
|
|
178 |
urls += [href]
|
179 |
return urls
|
180 |
def get_text(file):
|
181 |
+
message = email.message_from_bytes(file)
|
182 |
text_content = ""
|
183 |
for part in message.walk():
|
184 |
if part.get_content_type() == 'text/plain':
|
|
|
231 |
|
232 |
|
233 |
def get_email_html(file):
|
234 |
+
content = email.message_from_bytes(file)
|
235 |
html_content = ""
|
236 |
for part in content.walk():
|
237 |
if part.get_content_type() == 'text/html':
|
|
|
249 |
count = len(get_subject(file).split())
|
250 |
return count
|
251 |
def get_subject(file):
|
252 |
+
message = email.message_from_bytes(file)
|
253 |
headers = message.items()
|
254 |
# Print the headers
|
255 |
subject = ""
|
|
|
265 |
|
266 |
|
267 |
def get_sender(file):
|
268 |
+
message = email.message_from_bytes(file)
|
269 |
headers = message.items()
|
270 |
# Print the headers
|
271 |
sender = ""
|