feat(DynamicFetcher): add the ability to add init_script to context (#56)
This commit is contained in:
@@ -32,6 +32,7 @@ class PlaywrightConfig(Struct, kw_only=True, frozen=False):
|
||||
extra_headers: Optional[Dict[str, str]] = None
|
||||
useragent: Optional[str] = None
|
||||
timeout: int | float = 30000
|
||||
init_script: Optional[str] = None
|
||||
disable_resources: bool = False
|
||||
wait_selector: Optional[str] = None
|
||||
cookies: Optional[List[Dict]] = None
|
||||
@@ -58,6 +59,15 @@ class PlaywrightConfig(Struct, kw_only=True, frozen=False):
|
||||
if not self.selector_config:
|
||||
self.selector_config = {}
|
||||
|
||||
if self.init_script is not None:
|
||||
script_path = Path(self.init_script)
|
||||
if not script_path.exists():
|
||||
raise ValueError("Init script path not found")
|
||||
elif not script_path.is_file():
|
||||
raise ValueError("Init script is not a file")
|
||||
elif not script_path.is_absolute():
|
||||
raise ValueError("Init script is not a absolute path")
|
||||
|
||||
@staticmethod
|
||||
def __validate_cdp(cdp_url):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user