9
9
10
10
load_dotenv ()
11
11
12
+ API_KEY = os .getenv ("MALSHARE_API_KEY" )
12
13
13
14
def scrap_malshare ():
14
15
"""List hashes from the past 24 hours
15
16
"""
16
17
with Progress () as progress :
17
- api_key = os .getenv ("MALSHARE_API_KEY" )
18
- if api_key == "" :
19
- rich .print ("[red]Please set MALSHARE_API_KEY " )
18
+ if API_KEY is None or API_KEY == "" :
20
19
return None
21
20
try :
22
21
response = requests .post (
23
22
"https://malshare.com/api.php" ,
24
23
verify = True ,
25
- params = {"api_key" : api_key , "action" : "getlist" },
24
+ params = {"api_key" : API_KEY , "action" : "getlist" },
26
25
)
27
26
response .raise_for_status ()
28
27
hashes = response .json ()
29
28
except requests .RequestException as err :
30
- rich .print (f"[red] An error occurred: { err } " )
29
+ rich .print (f"[red] Malshare will be skipped. An expected error occurred: { err } " )
31
30
return None
32
31
rich .print (f"[green] - Malshare: { len (hashes )} Samples" )
33
32
sha256_ids = [hashe ["sha256" ] for hashe in hashes ]
@@ -43,7 +42,7 @@ def scrap_malshare():
43
42
try :
44
43
response = requests .post (
45
44
"https://malshare.com/api.php" ,
46
- params = {"api_key" : api_key , "action" : "getfile" , "hash" : sha256_id },
45
+ params = {"api_key" : API_KEY , "action" : "getfile" , "hash" : sha256_id },
47
46
verify = True ,
48
47
)
49
48
response .raise_for_status ()
0 commit comments