Instructions JavaScript
Transmettez un tableau JSON encodé en URL d’actions du navigateur à js_instructions. L’API les exécute dans l’ordre avant de renvoyer le HTML final. Utile pour les listes paginées, le défilement infini et les flux basés sur des formulaires.
Point de terminaison
Section intitulée « Point de terminaison » GET https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=<TARGET_URL>&render_js=1&js_instructions=<URL_ENCODED_JSON>
Paramètres
Section intitulée « Paramètres »| Paramètre | Type | Requis | Description |
|---|---|---|---|
api_key | string | oui | Votre clé API Web Scraping |
url | string | oui | URL cible à récupérer |
js_instructions | string | oui | Tableau JSON encodé en URL d’objets d’action. |
render_js | integer | oui | Doit être 1. |
Objet d’action
Section intitulée « Objet d’action »| Champ | Type | Description |
|---|---|---|
action | string | L’une des valeurs click, scrollTo, focus, value, ou submit (formulaires uniquement). |
selector | string | Sélecteur CSS pour l’élément cible. |
timeout | integer | Millisecondes à attendre après l’exécution de cette action. |
Exemple de requête
Section intitulée « Exemple de requête »[{"action":"scrollTo","selector":"div.navFooterBackToTop","timeout":5000,"block":"start"}]curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https://example.com&render_js=1&js_instructions=%5B%7B%22action%22%3A%22scrollTo%22%2C%22selector%22%3A%22div.navFooterBackToTop%22%2C%22timeout%22%3A%205000%2C%20%22block%22%3A%20%22start%22%7D%5D"import jsonimport requests
instructions = [{ "action": "scrollTo", "selector": "div.navFooterBackToTop", "timeout": 5000, "block": "start",}]r = requests.get("https://scrape.shifter.io/v1", params={ "api_key": "YOUR_API_KEY", "url": "https://example.com", "render_js": 1, "js_instructions": json.dumps(instructions),})print(r.text)import fetch from 'node-fetch';
const instructions = [{ action: 'scrollTo', selector: 'div.navFooterBackToTop', timeout: 5000, block: 'start',}];const url = 'https://scrape.shifter.io/v1?' + new URLSearchParams({ api_key: 'YOUR_API_KEY', url: 'https://example.com', render_js: '1', js_instructions: JSON.stringify(instructions),});const res = await fetch(url);console.log(await res.text());Exemple de réponse
Section intitulée « Exemple de réponse »<!doctype html><html><head> <title>Example Domain</title></head><body><div> <h1>Example Domain</h1> <p>This domain is for use in illustrative examples in documents.</p></div></body></html>