feat: add js_instructions parameter to ZenRowsScraper.scrape()
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import json
|
||||
import time
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Optional
|
||||
@@ -23,6 +24,7 @@ class ZenRowsScraper:
|
||||
wait: Optional[int] = None,
|
||||
wait_for: Optional[str] = None,
|
||||
premium_proxy: bool = False,
|
||||
js_instructions: Optional[list] = None,
|
||||
):
|
||||
"""Scrape a URL using ZenRows scraping SDK.
|
||||
|
||||
@@ -32,6 +34,7 @@ class ZenRowsScraper:
|
||||
wait: milliseconds to wait after page load
|
||||
wait_for: css selector to wait for
|
||||
premium_proxy: use residential proxy (ZenRows premium_proxy=true)
|
||||
js_instructions: list of ZenRows instruction dicts (evaluate, wait_for, click, etc.)
|
||||
"""
|
||||
self.logger.debug(f"ZenRows scraping url: {url}...")
|
||||
params: dict = {}
|
||||
@@ -43,6 +46,8 @@ class ZenRowsScraper:
|
||||
params["wait"] = str(wait)
|
||||
if wait_for is not None:
|
||||
params["wait_for"] = wait_for
|
||||
if js_instructions is not None:
|
||||
params["js_instructions"] = json.dumps(js_instructions)
|
||||
start = time.monotonic()
|
||||
response = self.client.get(url, params=params)
|
||||
elapsed_time = round((time.monotonic() - start) * 1000)
|
||||
|
||||
Reference in New Issue
Block a user