コンテンツにスキップ
ログイン サインアップ

タイムアウトの強制

一部のページでは、メインコンテンツの準備が整った後も、一部のDOMノードが長時間読み込まれ続けることがあります。timeout パラメータを使用して、レンダリング全体の時間に上限を設定してください。APIはタイマーが発火した時点で取得できているHTMLを返すか、利用可能なコンテンツが何も収集できなかった場合は説明付きのエラーとともに 422 を返します。

GET https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=<TARGET_URL>&render_js=1&timeout=<MILLISECONDS>
ParameterTypeRequiredDescription
api_keystringyesあなたのWeb Scraping APIキー
urlstringyes取得対象のURL
timeoutintegernoエンジンがレンダリングに費やせる最大時間(ミリ秒単位)。最大 60000
render_jsintegernoJavaScriptをレンダリングする場合は 1 を設定します。
Terminal window
curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https%3A%2F%2Fhttpbin.org%2Fget&render_js=1&timeout=200"
{
"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
}