Karim shoair commited on
Commit ·
e1a2fb1
1
Parent(s): b1c1b01
PlaywrightEngine - Validate CDP URLs in all cases
Browse files
scrapling/engines/pw.py
CHANGED
|
@@ -96,6 +96,9 @@ class PlaywrightEngine:
|
|
| 96 |
# 'token': ''
|
| 97 |
}
|
| 98 |
cdp_url = construct_cdp_url(cdp_url, config)
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
return cdp_url
|
| 101 |
|
|
|
|
| 96 |
# 'token': ''
|
| 97 |
}
|
| 98 |
cdp_url = construct_cdp_url(cdp_url, config)
|
| 99 |
+
else:
|
| 100 |
+
# To validate it
|
| 101 |
+
cdp_url = construct_cdp_url(cdp_url)
|
| 102 |
|
| 103 |
return cdp_url
|
| 104 |
|
scrapling/engines/toolbelt/navigation.py
CHANGED
|
@@ -6,7 +6,7 @@ import os
|
|
| 6 |
import logging
|
| 7 |
from urllib.parse import urlparse, urlencode
|
| 8 |
|
| 9 |
-
from scrapling.core._types import Union, Dict
|
| 10 |
from scrapling.engines.constants import DEFAULT_DISABLED_RESOURCES
|
| 11 |
|
| 12 |
from playwright.sync_api import Route
|
|
@@ -24,7 +24,7 @@ def intercept_route(route: Route) -> Union[Route, None]:
|
|
| 24 |
return route.continue_()
|
| 25 |
|
| 26 |
|
| 27 |
-
def construct_cdp_url(cdp_url: str, query_params: Dict) -> str:
|
| 28 |
"""Takes a CDP URL, reconstruct it to check it's valid, then adds encoded parameters if exists
|
| 29 |
|
| 30 |
:param cdp_url: The target URL.
|
|
|
|
| 6 |
import logging
|
| 7 |
from urllib.parse import urlparse, urlencode
|
| 8 |
|
| 9 |
+
from scrapling.core._types import Union, Dict, Optional
|
| 10 |
from scrapling.engines.constants import DEFAULT_DISABLED_RESOURCES
|
| 11 |
|
| 12 |
from playwright.sync_api import Route
|
|
|
|
| 24 |
return route.continue_()
|
| 25 |
|
| 26 |
|
| 27 |
+
def construct_cdp_url(cdp_url: str, query_params: Optional[Dict] = None) -> str:
|
| 28 |
"""Takes a CDP URL, reconstruct it to check it's valid, then adds encoded parameters if exists
|
| 29 |
|
| 30 |
:param cdp_url: The target URL.
|