# Google Trends

**SERP API Google 查詢參數**

使用 Thordata 的 SERP API 配置 Google 搜索查詢，包括地理定位參數、搜索類型以及「高級參數」輸出選項。

<details>

<summary><strong><code>q</code> ,</strong>搜尋查詢<strong>(必填)</strong></summary>

定義用於數據爬取的搜索查詢（默認值：`q=pizz`a）。支援任何語言的關鍵字。\
範例請求：\
使用參數 `q` 的範例：pizza

```sh
curl -X POST https://scraperapi.thordata.com/request \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Authorization: Bearer token" \
 -d "engine=google_trends" \
 -d "q=pizza" \
 -d "json=1"
```

</details>

## 地理位置

<details>

<summary><strong><code>hl</code> ,</strong>語言<strong>(非必填)</strong></summary>

設定搜尋結果的介面語言（預設值：en）。採用標準語言代碼格式（例如：`en、es、zh-CN`）。\
如需完整的支援語言代碼列表，請參考：[Google 語言代碼](https://developers.google.com/google-ads/api/docs/start)。

**範例請求**：

使用參數 q : pizza, hl : es 的範例結果

```sh
curl -X POST https://scraperapi.thordata.com/request \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Authorization: Bearer token" \
 -d "engine=google_trends" \
 -d "q=pizza" \
 -d "json=1" \
 -d "hl=es"
```

</details>

<details>

<summary><strong><code>geo</code> ,</strong>位置<strong>(非必填)</strong></summary>

此參數用於設定您希望搜尋的地理位置。預設值為全球範圍（當未設定或 `geo` 參數值為空時啟用）。完整支援的 Google Trends 地理位置清單請參閱：Google Trends 地理位置。

**範例請求：**

使用參數 `q` : pizza, `geo` : India 的範例結果

```
curl -X POST https://scraperapi.thordata.com/request \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Authorization: Bearer token" \
 -d "engine=google_trends" \
 -d "q=pizza" \
 -d "json=1" \
 -d "geo=India"
```

</details>

<details>

<summary><strong><code>region</code>,</strong>地區<strong>(非必填)</strong></summary>

此參數用於在使用「按地區比較區段」和「按地區興趣分佈」資料類型圖表時獲得更精確的結果。其他資料類型圖表不接受此區域參數。預設值取決於設定的地理區域。可用選項包括：

* `COUNTRY` - 國家
* `REGION` - 次區域
* `DMA` - 都會區
* `CITY` - 城市

**範例請求：**

使用參數 `q` : pizza, `region` : COUNTRY 的範例結果

```sh
curl -X POST https://scraperapi.thordata.com/request \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Authorization: Bearer token" \
 -d "engine=google_trends" \
 -d "q=pizza" \
 -d "json=1" \
 -d "region=COUNTRY"
```

</details>

## 搜尋類型

<details>

<summary><code>data_type</code> <strong>,</strong>資料型別<strong>(非必填)</strong></summary>

參數用於設定您要執行的搜尋類型。可用選項包括：

* **`TIMESERIES`** - 時間趨勢分析：可接受單一或多個查詢
* **`GEO_MAP`** - 區域比較分析：僅接受多個查詢
* **`GEO_MAP_0`** - 區域興趣分佈：僅接受單一查詢
* **`RELATED_TOPICS`** - 相關主題：僅接受單一查詢
* **`RELATED_QUERIES`** - 相關查詢：僅接受單一查詢

**範例請求：**

使用參數 **`q` : pizza, `data_type` : TIMESERIES** 的範例結果

```sh
curl -X POST https://scraperapi.thordata.com/request \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Authorization: Bearer token" \
 -d "engine=google_trends" \
 -d "q=pizza" \
 -d "json=1" \
 -d "data_type=TIMESERIES"
```

</details>

## 高級參數

<details>

<summary><code>tz</code><strong>,</strong>時區<strong>(非必填)</strong></summary>

此參數用於設定時區偏移量。預設值為 **420**（太平洋夏令時間 (PDT)：-07:00）。數值以分鐘為單位，範圍從 **-1439 至 1439**。

計算 **tz** 值的方法：\
取 UTC+0 與目標時區的時間差（以分鐘為單位）。例如：

* 太平洋夏令時間 (PDT, UTC-7) → `tz = -7 * 60 = -420`
* 臺灣標準時間 (TST, UTC+8) → `tz = 8 * 60 = 480`

**範例請求：**

使用參數 **`q` : pizza, `tz` : -420** 的範例結果（PDT 時區）

```sh
curl -X POST https://scraperapi.thordata.com/request \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Authorization: Bearer token" \
 -d "engine=google_trends" \
 -d "q=pizza" \
 -d "json=1" \
 -d "tz=-1439 to 1439"
```

</details>

<details>

<summary><code>cat</code>,類別 <strong>(非必填)</strong></summary>

此參數用於設定搜尋類別。預設值為 **0**（所有類別）。

**範例請求：**

使用參數 **`q` : pizza, `cat`: 7** 的範例結果

```sh
curl -X POST https://scraperapi.thordata.com/request \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Authorization: Bearer token" \
 -d "engine=google_trends" \
 -d "q=pizza" \
 -d "json=1" \
 -d "cat=7"
```

</details>

<details>

<summary><code>gprop</code> <strong>,</strong>財產<strong>(非必填)</strong></summary>

此參數用於按屬性類別排序搜尋結果。預設屬性為「網頁搜尋」（當未設定或 gprop 參數值為空時啟用）。其他可用選項包括：

* **`images`** - 圖片搜尋
* **`news`** - 新聞搜尋
* **`froogle`** - Google 購物
* **`youtube`** - YouTube 搜尋

**範例請求：**

使用參數 **`q` : pizza, `gprop` : froogle** 的搜尋結果

```sh
curl -X POST https://scraperapi.thordata.com/request \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Authorization: Bearer token" \
 -d "engine=google_trends" \
 -d "q=pizza" \
 -d "json=1" \
 -d "gprop=froogle"
```

</details>

<details>

<summary><code>date</code> <strong>,</strong>日期<strong>(非必填)</strong></summary>

此參數用於設定搜尋日期範圍。可用選項包括：

**預設時間範圍**：

* `now 1-H` - 過去1小時
* `now 4-H` - 過去4小時
* `now 1-d` - 過去1天
* `now 7-d` - 過去7天
* `today 1-m` - 過去30天
* `today 3-m` - 過去90天
* `today 12-m` - 過去12個月
* `today 5-y` - 過去5年
* `all` - 2004年至今

**自訂日期格式**（2004年至今）：\
`yyyy-mm-dd yyyy-mm-dd`（例如：`2021-10-15 2022-05-25`）

**範例請求：**

使用參數 `q : pizza, date : now 1-H` 的搜尋結果

```sh
curl -X POST https://scraperapi.thordata.com/request \
 -H "Content-Type: application/x-www-form-urlencoded" \
 -H "Authorization: Bearer token" \
 -d "engine=google_trends" \
 -d "q=pizza" \
 -d "json=1" \
 -d "date=now 1-H"
```

</details>

如需進一步幫助，請透過 **<support@thordata.com>** 聯繫我們。
