CSSを待機
wait_for_css にCSSセレクタを渡すと、APIはそのページを返す前に、その要素が出現するまで最大10秒間待機します。セレクタが一度も出現しなかった場合、リクエストは失敗し、課金されません。
Endpoint
Section titled “Endpoint” GET https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=<TARGET_URL>&wait_for_css=<CSS_SELECTOR>&render_js=1
Parameters
Section titled “Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
api_key | string | yes | Web Scraping APIキー |
url | string | yes | 取得対象のURL |
wait_for_css | string | yes | 待機対象のCSSセレクタ。 |
render_js | integer | yes | 1 である必要があります。 |
timeout | integer | no | 待機する最大時間(ミリ秒)。デフォルトは10000。 |
Example request
Section titled “Example request”curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https://example.com&wait_for_css=.firstHeading&render_js=1"import requests
r = requests.get("https://scrape.shifter.io/v1", params={ "api_key": "YOUR_API_KEY", "url": "https://example.com", "wait_for_css": ".firstHeading", "render_js": 1,})print(r.text)import fetch from 'node-fetch';
const url = 'https://scrape.shifter.io/v1?' + new URLSearchParams({ api_key: 'YOUR_API_KEY', url: 'https://example.com', wait_for_css: '.firstHeading', render_js: '1',});const res = await fetch(url);console.log(await res.text());Example response
Section titled “Example response”<!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>