feature: действие inner_text; запросы v2 в test_main.http
This commit is contained in:
1 parent
6ce8a8c648
commit
49a2f3024a
3 files changed
+27
-8
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import asyncio
|
||||
import re
|
||||
import time
|
||||
|
||||
from patchright.async_api import Page
|
||||
@@ -71,6 +72,13 @@ async def inner_html(page: Page, act: ActionRequest, **kwargs) -> str | None:
|
||||
return await element.inner_html()
|
||||
|
||||
|
||||
@register
|
||||
async def inner_text(page: Page, act: ActionRequest, **kwargs) -> str | None:
|
||||
html_source = await inner_html(page, act, **kwargs)
|
||||
text = re.sub(r"<[^>]+>", "", html_source)
|
||||
return text
|
||||
|
||||
|
||||
@register
|
||||
async def wait_for(page: Page, act: ActionRequest, **kwargs) -> str | None:
|
||||
await page.wait_for_selector(act.selector, timeout=act.timeout * 1000)
|
||||
|
||||
@@ -17,6 +17,7 @@ _REQUIRED_FIELDS: dict[str, tuple[str, ...]] = {
|
||||
"click": ("selector",),
|
||||
"submit": ("selector",),
|
||||
"inner_html": ("selector",),
|
||||
"inner_text": ("selector",),
|
||||
"wait_for": ("selector",),
|
||||
"pass_challenge": (),
|
||||
}
|
||||
|
||||
+18
-8
@@ -109,19 +109,29 @@ X-API-Key: <key>
|
||||
|
||||
### 2f2100be-6ce7-40d5-bae5-61424b2504c8
|
||||
|
||||
POST http://127.0.0.1:8000/v1/solve
|
||||
POST http://localhost:8002/v2/tasks
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
X-API-Key: <key>
|
||||
|
||||
{
|
||||
"url": "https://ifconfig.me/",
|
||||
"proxy": "http://7LLkWF:yecUzT@200.10.32.226:8000",
|
||||
"actions": [
|
||||
{"type": "wait_for", "selector": "#ip_address", "timeout": 10},
|
||||
{"type": "inner_html", "selector": "#ip_address"}
|
||||
]
|
||||
"url": "https://freelancehunt.com/",
|
||||
"proxy": "http://BQLo3X:poqAWX@168.81.43.154:8000",
|
||||
"actions": [
|
||||
{
|
||||
"type": "inner_text",
|
||||
"selector": "//section[@class='hero']//div[@class='hero__content']/h2/span[2]"
|
||||
}
|
||||
],
|
||||
"captcha_type": "cloudflare",
|
||||
"browser_idle_timeout": 0
|
||||
}
|
||||
|
||||
###
|
||||
|
||||
### b8f770a3-38c2-45f2-944b-2703798e3503
|
||||
GET http://localhost:8002/v2/tasks/4d8105f8-93a8-43ee-aa6e-db917451363b
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
X-API-Key: <key>
|
||||
|
||||
###
|
||||
Reference in new issue
Block a user