Google 検索 APIクイックスタートはじめる

はじめに

エンドポイント

POST https://api.scrapeless.com/api/v1/scraper/request

すべてのリクエストは、x-api-token ヘッダーを使用して API キーで認証してください。

リクエストボディ

パラメータ説明
actorstring実行するサービスを表す非常に重要なパラメータです。Google Search API には scraper.google.search を使用してください。
inputobjectアクターがデータスクレイピングタスクを完了するために必要なパラメータです。API パラメータ を参照してください。
proxyobjectcountry フィールド — リクエスト送信にこの地域のプロキシを使用します。

タスク成功時の説明

  • HTTP ステータスコード 200 はタスクが成功したことを示し、レスポンスボディがデータとなります。

タスク処理中の説明

  • HTTP ステータスコード 201 はタスクが処理中であることを示します。taskId を使用してタスクの結果を取得してください。
{ "message": "task in progress", "taskId": "30681c8b-bfd3-48eb-a7c9-006e40b00591" }

タスク失敗時の説明

  • HTTP ステータスコード 429:リクエストが多すぎます。
  • HTTP ステータスコード 400:タスクパラメータが有効か確認してください。
  • HTTP ステータスコード 500:内部サーバーエラー。

リクエスト例

Google 検索データの取得

curl --location 'https://api.scrapeless.com/api/v1/scraper/request' \
--header 'x-api-token: <api-key>' \
--header 'Content-Type: application/json' \
--data '{
    "actor": "scraper.google.search",
    "input": {
        "q": "coffee",
        "hl": "en",
        "gl": "us"
    }
}'

レスポンス例

リクエストが成功すると、構造化された JSON が返されます。以下の例は可読性のために省略されています。長い base64 の thumbnail/favicon の値は短縮され、配列の繰り返し項目は省略されています。

{
  "knowledge_graph": {
    "web_results": [
      {
        "link": "https://www.google.com/goto?url=CAESXAHrOzAVxWzBf4WvYxeVZ8Zo_Siv13akQaBbvGofI_ClLpVLHlRUsspJCVqpsphurR92LMRUV8EmuZ_IZ7lqN5pOWGRRLe7nEPPR6KjahnP1IVXaxsIqlP3xDakG"
      }
    ],
    "source": {}
  },
  "latest_posts": [
    {
      "title": "What's one coffee thing you used to care about that you don't anymore?",
      "link": "/goto?url=CAESmQEB6zswFVfIdcw56inl6eK4LHHs9d5OgGnu34d-gRX82gCIHEBAi7sC_8lq2bhRdqDC..."
    },
    {
      "title": "This Isn't Coffee. It's A Milkshake",
      "link": "/goto?url=CAESYwHrOzAVAkWf2LCzzmZ5cYYZHvuiF-TFXsr0xgPBY7amqrvK...",
      "duration": "14:02"
    }
  ],
  "local_map": {
    "link": "https://www.google.com/search?q=coffee&gl=us&hl=en&udm=1&...",
    "image": "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",
    "gps_coordinates": null
  },
  "local_results": {
    "places": [
      {
        "position": 1,
        "rating": 4.9,
        "reviews": 404,
        "reviews_original": "(404)",
        "price": "$",
        "thumbnail": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAgGBhMSERQTERAT...",
        "gps_coordinates": { "latitude": 0, "longitude": 0 },
        "title": "Sip 305 (Kendall)",
        "type": " Coffee shop",
        "address": "Miami, FL",
        "phone": " $1–10 ",
        "hours": "4.9(404) ",
        "extensions": [
          "       \"Their coffee is so delicious and the customer service is always great.\""
        ]
      }
    ]
  },
  "metadata": {
    "engine": "google.search",
    "rawUrl": "https://api.scrapeless.com/storage/scrapeless.scraper.google.search/47c34678dc1d382b9c1d633559f82b89/b2472d195c682e2264ad95e0b8e7e9d9_1788487566.html"
  },
  "nutrition_information": {
    "description": "Coffee",
    "source": "USDA",
    "source_link": "google.com/goto?url=CAESbgHrOzAVw0vv2_vO0iW_QFtYMi1P7TFKGvdW231MF54OnwbaAfA...",
    "amount_per": "1 cup (8 fl oz) (237 g)",
    "calories": "1"
  },
  "organic_results": [
    {
      "position": 1,
      "title": "Coffee",
      "link": "https://en.wikipedia.org/wiki/Coffee",
      "redirect_link": "https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=CAESXAHrOzAVxWzBf4WvYxeVZ8Zo...",
      "favicon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAAAAABXZoBI...",
      "snippet": "Coffee is a beverage brewed from roasted, ground coffee beans. Dark-colored and bitter, coffee has a stimulating effect on humans due to its caffeine content;",
      "snippet_highlighted_words": [
        "a beverage brewed from roasted, ground coffee beans"
      ],
      "source": "Wikipedia"
    },
    {
      "position": 2,
      "title": "What is coffee? - NCA",
      "link": "https://www.aboutcoffee.org/origins/what-is-coffee/",
      "redirect_link": "https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=CAESawHrOzAVyp_BFOSj6O7zNYMsei_u8U1j8IcMB8f0Xqc6s67gnMuSxh70owMF6mQ0L1K0bm...",
      "favicon": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAMAAABF0y+m...",
      "snippet": "What is coffee made of? Learn about the coffee tree, its lifespan, how it produces coffee beans, and the two most common coffee species, arabica and ...",
      "snippet_highlighted_words": [
        "Learn about the coffee tree, its lifespan, how it produces coffee beans"
      ],
      "source": "About Coffee - National Coffee Association"
    }
  ],
  "pagination": {
    "current": 1,
    "next": "https://www.google.com/search?q=coffee&gl=us&hl=en&start=10&...",
    "other_pages": {
      "2": "https://www.google.com/search?q=coffee&gl=us&hl=en&start=10&...",
      "3": "https://www.google.com/search?q=coffee&gl=us&hl=en&start=20&..."
    }
  },
  "search_information": {
    "organic_results_state": "Results for exact spelling",
    "query_displayed": "coffee",
    "total_results": 0,
    "time_taken_displayed": ""
  }
}