Spaces:
Running
Running
Update hcaptcha_solver.py
Browse files- hcaptcha_solver.py +11 -5
hcaptcha_solver.py
CHANGED
@@ -7,7 +7,7 @@ import requests
|
|
7 |
from hcaptcha_challenger.agents import Malenia
|
8 |
from playwright.async_api import BrowserContext as ASyncContext, async_playwright
|
9 |
|
10 |
-
nopecha.api_key = '
|
11 |
|
12 |
|
13 |
async def route_continuation(route, request, host, sitekey):
|
@@ -95,7 +95,13 @@ def url_to_base64(url):
|
|
95 |
async def on_response(response, page):
|
96 |
if response.url.startswith("https://api.hcaptcha.com/getcaptcha"):
|
97 |
# 获取响应内容
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
# 打印响应内容
|
100 |
print(data)
|
101 |
examples_urls = data.get("requester_question_example")
|
@@ -182,7 +188,7 @@ async def area_click(page, data, round0, examples):
|
|
182 |
await locator.click(delay=200, position={"x": int(bounds["width"] * clicks["x"] / 100),
|
183 |
"y": int(bounds["height"] * clicks["y"] / 100)})
|
184 |
print("done")
|
185 |
-
|
186 |
fl = frame_challenge.locator("//div[@class='button-submit button']")
|
187 |
await fl.click()
|
188 |
await asyncio.sleep(random.uniform(0.1, 0.3))
|
@@ -218,10 +224,10 @@ tasks = None
|
|
218 |
token = None
|
219 |
|
220 |
|
221 |
-
async def main(host,key):
|
222 |
global tasks, token
|
223 |
try:
|
224 |
-
tasks = asyncio.gather(bytedance(host,key),
|
225 |
return_exceptions=True)
|
226 |
await tasks
|
227 |
return token
|
|
|
7 |
from hcaptcha_challenger.agents import Malenia
|
8 |
from playwright.async_api import BrowserContext as ASyncContext, async_playwright
|
9 |
|
10 |
+
nopecha.api_key = '5nogeisu16i5tr5r'
|
11 |
|
12 |
|
13 |
async def route_continuation(route, request, host, sitekey):
|
|
|
95 |
async def on_response(response, page):
|
96 |
if response.url.startswith("https://api.hcaptcha.com/getcaptcha"):
|
97 |
# 获取响应内容
|
98 |
+
content_type = response.headers.get('Content-Type')
|
99 |
+
if content_type == "application/json":
|
100 |
+
data = await response.json()
|
101 |
+
else:
|
102 |
+
print("content type:", content_type)
|
103 |
+
content = await response.content()
|
104 |
+
data = content.decode('utf-8')
|
105 |
# 打印响应内容
|
106 |
print(data)
|
107 |
examples_urls = data.get("requester_question_example")
|
|
|
188 |
await locator.click(delay=200, position={"x": int(bounds["width"] * clicks["x"] / 100),
|
189 |
"y": int(bounds["height"] * clicks["y"] / 100)})
|
190 |
print("done")
|
191 |
+
|
192 |
fl = frame_challenge.locator("//div[@class='button-submit button']")
|
193 |
await fl.click()
|
194 |
await asyncio.sleep(random.uniform(0.1, 0.3))
|
|
|
224 |
token = None
|
225 |
|
226 |
|
227 |
+
async def main(host, key):
|
228 |
global tasks, token
|
229 |
try:
|
230 |
+
tasks = asyncio.gather(bytedance(host, key),
|
231 |
return_exceptions=True)
|
232 |
await tasks
|
233 |
return token
|