타임아웃 강제 적용
일부 페이지는 메인 콘텐츠가 준비된 후에도 몇몇 DOM 노드가 오랫동안 로딩 상태를 유지합니다. timeout 파라미터를 사용하여 전체 렌더링 시간을 제한하세요. 타이머가 종료되면 API는 그 시점까지 수집된 HTML을 반환하거나, 사용 가능한 데이터가 전혀 없는 경우 설명이 포함된 오류와 함께 422를 반환합니다.
Endpoint
섹션 제목: “Endpoint” GET https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=<TARGET_URL>&render_js=1&timeout=<MILLISECONDS>
Parameters
섹션 제목: “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
api_key | string | yes | Web Scraping API 키 |
url | string | yes | 가져올 대상 URL |
timeout | integer | no | 엔진이 렌더링에 사용할 수 있는 최대 시간(밀리초). 최대값은 60000입니다. |
render_js | integer | no | JavaScript를 렌더링하려면 1로 설정하세요. |
Example request
섹션 제목: “Example request”curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https%3A%2F%2Fhttpbin.org%2Fget&render_js=1&timeout=200"import requests
r = requests.get("https://scrape.shifter.io/v1", params={ "api_key": "YOUR_API_KEY", "url": "https://httpbin.org/get", "render_js": 1, "timeout": 200,})print(r.json())import fetch from 'node-fetch';
const url = 'https://scrape.shifter.io/v1?' + new URLSearchParams({ api_key: 'YOUR_API_KEY', url: 'https://httpbin.org/get', render_js: '1', timeout: '200',});const res = await fetch(url);console.log(await res.json());Example response
섹션 제목: “Example response”{ "status": "Failure", "status_code": 422, "created_at": "2022-04-26T11:57:23.242Z", "processed_at": "2022-04-26T11:57:23.739Z", "time_taken": { "total": 0.701, "scraping": 0.202, "setup_worker": 0.403 }, "error": "The target page took more than 0.2 seconds to load, the website might be down. Retry the request or increase the value of 'timeout' parameter.", "page_content": null}