@@ -20,6 +20,7 @@ def find_keywords_in_pdfs(ps_docs_path, keywords: list) -> dict:
20
20
try :
21
21
pdf_files = [f for f in os .listdir (ps_docs_path ) if f .lower ().endswith (".pdf" )]
22
22
results = {}
23
+ pdf_with_keywords = 0
23
24
for pdf_file in pdf_files :
24
25
pdf_path = os .path .join (ps_docs_path , pdf_file )
25
26
extracted_text = extract_text_from_pdf (pdf_path )
@@ -28,7 +29,8 @@ def find_keywords_in_pdfs(ps_docs_path, keywords: list) -> dict:
28
29
if pdf_file not in results :
29
30
results [pdf_file ] = []
30
31
results [pdf_file ].append (keyword )
31
- return results
32
+ pdf_with_keywords += 1
33
+ return results , pdf_with_keywords
32
34
except Exception as e :
33
35
print (Fore .RED + f"Can't find keywords. Reason: { e } " )
34
36
pass
@@ -162,7 +164,7 @@ def subdomains_parser(subdomains_list, report_folder, keywords, keywords_flag):
162
164
if keywords_flag == 1 :
163
165
print (Fore .GREEN + "Searching keywords in PDF files..." + Style .RESET_ALL )
164
166
try :
165
- pdf_results = find_keywords_in_pdfs (ps_docs_path , keywords )
167
+ pdf_results , pdf_with_keywords = find_keywords_in_pdfs (ps_docs_path , keywords )
166
168
for pdf_file , found_keywords in pdf_results .items ():
167
169
print (Fore .GREEN + f"Keywords " + Fore .LIGHTCYAN_EX + Style .BRIGHT + f"{ ', ' .join (found_keywords )} " + Style .RESET_ALL + Fore .GREEN + f" found in '{ pdf_file } '" + Style .RESET_ALL )
168
170
except Exception as e :
@@ -174,4 +176,8 @@ def subdomains_parser(subdomains_list, report_folder, keywords, keywords_flag):
174
176
print (Fore .GREEN + f"[+] Among them, { accessible_subdomains } subdomains were accessible" )
175
177
print (Fore .GREEN + f"[+] In result, { len (ps_emails_return )} unique e-mail addresses were found" )
176
178
print (Fore .GREEN + f"[+] Also, { files_counter } files were extracted" )
179
+ if keywords_flag == 0 :
180
+ print (Fore .GREEN + "[+] Keywords were not gathered because of None user input" )
181
+ else :
182
+ print (Fore .GREEN + f"[+] Total { pdf_with_keywords } keywords were found in PDF files" )
177
183
return ps_emails_return
0 commit comments