JavaScriptのレンダリング
初回のHTML読み込み後にコンテンツをハイドレートするシングルページアプリケーションやサイトは、完全にレンダリングするために実際のブラウザを必要とします。render_js=1 を渡すことで、スクレイプをヘッドレスブラウザ経由で実行し、完全にレンダリングされたHTMLを受け取ることができます。
エンドポイント
Section titled “エンドポイント” GET https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=<TARGET_URL>&render_js=1
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
api_key | string | はい | Web Scraping APIキー |
url | string | はい | 取得対象のURL |
render_js | integer | いいえ | 0(デフォルト)または 1。ヘッドレスブラウザでレンダリングするには 1 を設定します。 |
リクエスト例
Section titled “リクエスト例”curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https://example.com&render_js=1"import requests
r = requests.get("https://scrape.shifter.io/v1", params={ "api_key": "YOUR_API_KEY", "url": "https://example.com", "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', render_js: '1',});const res = await fetch(url);console.log(await res.text());レスポンス例
Section titled “レスポンス例”<!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> <p><a href="https://www.iana.org/domains/example">More information...</a></p></div></body></html>