Scrapling / scrapling /core /_shell_signatures.py
Karim shoair
fix: update shell signatures for the autocompletion
05b2188
from scrapling.core._types import (
Any,
Dict,
List,
Tuple,
Sequence,
Callable,
Optional,
SetCookieParam,
SelectorWaitStates,
)
# Parameter definitions for shell function signatures (defined once at module level)
# Mirrors TypedDict definitions from _types.py but runtime-accessible for IPython introspection
_REQUESTS_PARAMS = {
"params": Optional[Dict | List | Tuple],
"cookies": Any,
"auth": Optional[Tuple[str, str]],
"impersonate": Any,
"http3": Optional[bool],
"stealthy_headers": Optional[bool],
"proxies": Any,
"proxy": Optional[str],
"proxy_auth": Optional[Tuple[str, str]],
"timeout": Optional[int | float],
"headers": Any,
"retries": Optional[int],
"retry_delay": Optional[int],
"follow_redirects": Optional[bool],
"max_redirects": Optional[int],
"verify": Optional[bool],
"cert": Optional[str | Tuple[str, str]],
"selector_config": Optional[Dict],
}
_FETCH_PARAMS = {
"headless": bool,
"disable_resources": bool,
"network_idle": bool,
"load_dom": bool,
"wait_selector": Optional[str],
"wait_selector_state": SelectorWaitStates,
"cookies": Sequence[SetCookieParam],
"google_search": bool,
"wait": int | float,
"timezone_id": str | None,
"page_action": Optional[Callable],
"proxy": Optional[str | Dict[str, str] | Tuple],
"extra_headers": Optional[Dict[str, str]],
"timeout": int | float,
"init_script": Optional[str],
"user_data_dir": str,
"selector_config": Optional[Dict],
"additional_args": Optional[Dict],
"locale": Optional[str],
"real_chrome": bool,
"cdp_url": Optional[str],
"useragent": Optional[str],
"extra_flags": Optional[List[str]],
}
_STEALTHY_FETCH_PARAMS = {
"headless": bool,
"disable_resources": bool,
"network_idle": bool,
"load_dom": bool,
"wait_selector": Optional[str],
"wait_selector_state": SelectorWaitStates,
"cookies": Sequence[SetCookieParam],
"google_search": bool,
"wait": int | float,
"timezone_id": str | None,
"page_action": Optional[Callable],
"proxy": Optional[str | Dict[str, str] | Tuple],
"extra_headers": Optional[Dict[str, str]],
"timeout": int | float,
"init_script": Optional[str],
"user_data_dir": str,
"selector_config": Optional[Dict],
"additional_args": Optional[Dict],
"locale": Optional[str],
"real_chrome": bool,
"cdp_url": Optional[str],
"useragent": Optional[str],
"extra_flags": Optional[List[str]],
"allow_webgl": bool,
"hide_canvas": bool,
"block_webrtc": bool,
"solve_cloudflare": bool,
}
# Mapping of function names to their parameter definitions
Signatures_map = {
"get": _REQUESTS_PARAMS,
"post": {**_REQUESTS_PARAMS, "data": Optional[Dict | str], "json": Optional[Dict | List]},
"put": {**_REQUESTS_PARAMS, "data": Optional[Dict | str], "json": Optional[Dict | List]},
"delete": _REQUESTS_PARAMS,
"fetch": _FETCH_PARAMS,
"stealthy_fetch": _STEALTHY_FETCH_PARAMS,
}