Spaces:
Running
Running
zhou12189108
commited on
Commit
•
0d3cc7b
1
Parent(s):
0114a7e
Update hcaptcha_solver.py
Browse files- hcaptcha_solver.py +28 -24
hcaptcha_solver.py
CHANGED
@@ -124,30 +124,34 @@ async def on_response(response, page):
|
|
124 |
|
125 |
|
126 |
async def classify_click(page, data, round0, examples):
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
|
|
|
|
|
|
151 |
|
152 |
|
153 |
async def area_click(page, data, round0, examples):
|
|
|
124 |
|
125 |
|
126 |
async def classify_click(page, data, round0, examples):
|
127 |
+
try:
|
128 |
+
await page.wait_for_selector("//iframe[contains(@title, 'hCaptcha challenge')]")
|
129 |
+
frame_challenge = page.frame_locator("//iframe[contains(@title, 'hCaptcha challenge')]")
|
130 |
+
samples = frame_challenge.locator("//div[@class='task-image']")
|
131 |
+
await frame_challenge.locator("//div[@tabindex='0']").nth(0).wait_for()
|
132 |
+
count = await samples.count()
|
133 |
+
print(count)
|
134 |
+
clicks = nopecha.Recognition.solve(
|
135 |
+
type='hcaptcha',
|
136 |
+
task=data.get("requester_question").get("en"),
|
137 |
+
image_urls=[data.get("tasklist")[i]["datapoint_uri"] for i in (range(9) if round0 == 0 else range(9, 18))],
|
138 |
+
image_examples=examples
|
139 |
+
)
|
140 |
+
for i in range(count):
|
141 |
+
sample = samples.nth(i)
|
142 |
+
await sample.wait_for()
|
143 |
+
if clicks[i]:
|
144 |
+
print("try to click")
|
145 |
+
await sample.click(delay=200)
|
146 |
+
print(clicks)
|
147 |
+
await asyncio.sleep(random.uniform(0.1, 0.3))
|
148 |
+
fl = frame_challenge.locator("//div[@class='button-submit button']")
|
149 |
+
await fl.click()
|
150 |
+
if round0 == 0:
|
151 |
+
await classify_click(page, data, 1, examples)
|
152 |
+
except Exception as e:
|
153 |
+
print(e)
|
154 |
+
await classify_click(page, data, round0, examples)
|
155 |
|
156 |
|
157 |
async def area_click(page, data, round0, examples):
|