File size: 3,071 Bytes
0e7f15c
 
05b2188
0e7f15c
 
05b2188
 
0e7f15c
05b2188
 
0e7f15c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
05b2188
 
 
 
 
 
0e7f15c
 
05b2188
 
 
0e7f15c
 
 
05b2188
97e2d5a
05b2188
 
 
 
 
 
0e7f15c
 
 
 
 
 
 
 
05b2188
 
0e7f15c
05b2188
 
 
 
0e7f15c
05b2188
 
 
97e2d5a
0e7f15c
05b2188
 
 
 
 
 
 
 
 
0e7f15c
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
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,
}