@@ -35,7 +35,7 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
35
35
"gemini-1.5-flash" : {'mode' : True , 'id' : 'Gemini' },
36
36
"llama-3.1-8b" : {'mode' : True , 'id' : "llama-3.1-8b" },
37
37
'llama-3.1-70b' : {'mode' : True , 'id' : "llama-3.1-70b" },
38
- 'llama-3.1-405b' : {'mode' : True , 'id' : "llama-3.1-405" },
38
+ 'llama-3.1-405b' : {'mode' : True , 'id' : "llama-3.1-405" },
39
39
#
40
40
'Python Agent' : {'mode' : True , 'id' : "Python Agent" },
41
41
'Java Agent' : {'mode' : True , 'id' : "Java Agent" },
@@ -86,21 +86,23 @@ class Blackbox(AsyncGeneratorProvider, ProviderModelMixin):
86
86
87
87
@classmethod
88
88
async def fetch_validated (cls ):
89
+ # Якщо ключ вже збережений в пам'яті, повертаємо його
90
+ if cls ._last_validated_value :
91
+ return cls ._last_validated_value
92
+
93
+ # Якщо ключ не знайдено, виконуємо пошук
89
94
async with aiohttp .ClientSession () as session :
90
95
try :
91
- # Get the HTML of the page
92
96
async with session .get (cls .url ) as response :
93
97
if response .status != 200 :
94
98
print ("Failed to load the page." )
95
99
return cls ._last_validated_value
96
100
97
101
page_content = await response .text ()
98
- # Find all JavaScript file links
99
102
js_files = re .findall (r'static/chunks/\d{4}-[a-fA-F0-9]+\.js' , page_content )
100
103
101
104
key_pattern = re .compile (r'w="([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})"' )
102
105
103
- # Check each JavaScript file for the key
104
106
for js_file in js_files :
105
107
js_url = f"{ cls .url } /_next/{ js_file } "
106
108
async with session .get (js_url ) as js_response :
@@ -109,7 +111,7 @@ async def fetch_validated(cls):
109
111
match = key_pattern .search (js_content )
110
112
if match :
111
113
validated_value = match .group (1 )
112
- cls ._last_validated_value = validated_value
114
+ cls ._last_validated_value = validated_value # Зберігаємо в пам'яті
113
115
return validated_value
114
116
except Exception as e :
115
117
print (f"Error fetching validated value: { e } " )
0 commit comments