import requests def read_text(file_name): file_data = [] text_file = open(file_name,"r") for word in text_file.read().split(): file_data.append(word) text_file.close() return file_data the_list = read_text("IOC.txt") for i in the_list: url = f"https://www.virustotal.com/api/v3/files/{i}/analyse" headers = { "accept": "application/json", "x-apikey": "c6e0fd1954e15147516bb633827f3e8b16e26cf6560885671804509e8b41cf0c" } try: response = requests.post(url, headers=headers) print(response.text) except requests.exceptions.HTTPError as e: if "404" in str(e): print( '404 response returned likely meaning no file hash matches have been found.\n') else: print(f'API response: {e}') print( 'For more information visit: https://developers.virustotal.com/reference/errors\n')