基本的なリクエスト
最もシンプルなWeb Scraping APIの呼び出しには、api_keyと対象のurlという2つのパラメータのみが必要です。APIはページの生のHTMLを返し、あわせてリクエストの内容を示すカスタムレスポンスヘッダーをいくつか返します。
エンドポイント
Section titled “エンドポイント” GET https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=<TARGET_URL>
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
api_key | string | yes | Web Scraping APIのAPIキー |
url | string | yes | 取得対象のURL |
カスタムレスポンスヘッダー
Section titled “カスタムレスポンスヘッダー”APIは、スクレイピングが成功するたびにWSA-から始まるレスポンスヘッダーをいくつか追加します。
| ヘッダー | 説明 |
|---|---|
WSA-Client-Cookies | 対象ページの読み込み後にJavaScriptによって生成されたクッキー。 |
WSA-Scraped-Headers | スクレイピング対象のURLから返されたレスポンスヘッダー。 |
WSA-Scraped-Resolved-Url | リダイレクト後の最終的なURL。 |
WSA-Call-Credit-Usage | このリクエストで消費されたクレジット数。 |
WSA-Current-Credit-Usage | このリクエスト後のクレジット使用量の合計。 |
リクエスト例
Section titled “リクエスト例”curl "https://scrape.shifter.io/v1?api_key=YOUR_API_KEY&url=https://example.com"import requests
r = requests.get("https://scrape.shifter.io/v1", params={ "api_key": "YOUR_API_KEY", "url": "https://example.com",})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',});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>- APIリクエスト - パラメータの完全なリファレンス
- JavaScriptのレンダリング
- APIエラー