# 鉅亨網爬蟲｜台股報價、財經新聞、輿情一鍵匯出（免 API） (`claude_code_reviewer/cnyes-scraper`) Actor

免登入抓鉅亨網財經資料：財經新聞列表／搜尋與台股個股即時報價，含漲跌、當日高低與 52 週高低，輸出 JSON／CSV／Excel。金融數據、量化研究、輿情分析必備。

- **URL**: https://apify.com/claude\_code\_reviewer/cnyes-scraper.md
- **Developed by:** [Chad](https://apify.com/claude_code_reviewer) (community)
- **Categories:** AI, Automation, News
- **Stats:** 2 total users, 0 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 財經新聞

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## 鉅亨網爬蟲｜台股報價、財經新聞一鍵下載（免 API、免登入）

一個 Actor 搞定鉅亨網（cnyes.com）兩種你會用到的抓取模式：**財經新聞**（分類列表或關鍵字搜尋，含相關個股標籤）與**個股即時報價**（台股上市代號，最新價、漲跌、高低價）。不需要登入、不需要 API token，批量貼上關鍵字或股票代號都吃得下。全程走 cnyes 官方 JSON 端點，不開瀏覽器，速度快、成本低。

給誰用的：做財經輿情分析的、跑量化 dashboard 需要股價時序的、寫市場調查報告的、追蹤特定產業新聞流的、論文需要財經資料集的、自己寫 side project 的工程師。

***

### 能抓到什麼

每一筆資料都會拿到下面這些欄位（缺值一律回 `null`，不會少欄位；`news`/`quote` 兩組欄位共用一張表，當下模式沒填的欄位一律 `null`）：

| 欄位             | 說明                       | 範例                                     | 可用模式 |
| ---------------- | -------------------------- | ---------------------------------------- | -------- |
| `title`          | 新聞標題                   | `台積電法說會釋利多`                     | news 只  |
| `summary`        | 新聞摘要                   | —                                        | news 只  |
| `content`        | 新聞內文（HTML）           | —                                        | news 只  |
| `source`         | 新聞來源                   | `鉅亨網`                                 | news 只  |
| `category`       | 分類名稱                   | `台股新聞`                               | news 只  |
| `related_stocks` | 相關個股代號陣列（從新聞內文標記的關聯個股解析出代號） | `["3130"]`                | news 只  |
| `keyword`        | 新聞關鍵字標籤（逗號串接） | `台積電,晶圓代工`                        | news 只  |
| `published_at`   | 發布時間（ISO 8601）       | `2026-07-04T04:51:37.000Z`               | news 只  |
| `news_url`       | 新聞網址                   | `https://news.cnyes.com/news/id/6522436` | news 只  |
| `stock_code`     | 股票代號                   | `2330`                                   | quote 只 |
| `symbol`         | cnyes 內部代碼             | `TWS:2330:STOCK`                         | quote 只 |
| `last_price`     | 最新價                     | `2445`                                   | quote 只 |
| `change`         | 漲跌（元）                 | `-20`                                    | quote 只 |
| `change_pct`     | 漲跌幅（%）                | `-0.81`                                  | quote 只 |
| `day_high`       | 當日最高                   | `2465`                                   | quote 只 |
| `day_low`        | 當日最低                   | `2415`                                   | quote 只 |
| `day_open`       | 開盤價                     | `2415`                                   | quote 只 |
| `prev_close`     | 昨收價                     | `2465`                                   | quote 只 |
| `week52_high`    | 52 週最高                  | `2710`                                   | quote 只 |
| `week52_low`     | 52 週最低                  | `2220`                                   | quote 只 |
| `volume`         | 成交量（v1.0 一律 `null`） | —                                        | —        |
| `quote_time`     | 報價時間（ISO 8601）       | `2026-07-03T05:30:00.000Z`               | quote 只 |
| `quote_url`      | 個股報價頁網址             | `https://www.cnyes.com/twstock/2330`     | quote 只 |
| `source_mode`    | 這筆從哪個模式來的         | `news`、`quote`                          | 兩者     |
| `source_query`   | 抓取時用的查詢條件         | `tw_stock`、`台積電`、`2330`             | 兩者     |
| `scraped_at`     | 抓取當下時間（ISO 8601）   | `2026-07-03T05:39:30.164Z`               | 兩者     |

**重要：`news` 模式只填新聞相關欄位，`quote` 模式相關欄位一律 `null`；反之亦然。`volume`（成交量）v1.0 一律 `null`，cnyes 即時報價端點的成交量碼待對照確認，規劃於 v1.1 補齊。**

***

### 兩種模式一個爬蟲

| 模式         | 幹嘛用的                                     | 計費事件                 | 單價   |
| ------------ | -------------------------------------------- | ------------------------ | ------ |
| 📰 **news**  | 財經新聞：分類列表（如台股新聞）或關鍵字搜尋 | `search-listing`（每筆） | $0.002 |
| 📈 **quote** | 依股票代號抓台股上市個股即時報價             | `product-detail`（每筆） | $0.008 |

不管跑哪個模式，每次 Run 啟動都會額外收一次性的 `apify-actor-start` 費用 **$0.005**。所有計費都在資料成功寫入 dataset **之後**才會收，Run 結束時 log 會印出 `total_items / charged / skipped` 讓你對帳。

一次跑一個 mode，從 Apify Console 的下拉選單選就好。

***

### 輸入欄位

| 欄位           | 型別     |       必填       |    預設    | 說明                                                                                                                     |
| -------------- | -------- | :--------------: | :--------: | ------------------------------------------------------------------------------------------------------------------------ |
| `mode`         | enum     |      建議填      |   `news`   | `news`（財經新聞）/ `quote`（個股報價）擇一。                                                                            |
| `newsCategory` | string   |       選填       | `tw_stock` | 財經新聞分類代碼，常見：`tw_stock`（台股）、`headline`（焦點）、`tw_money`（理財）。未填 `keywords` 時預設抓這個分類。   |
| `keywords`     | string\[] |       選填       |     —      | 財經新聞關鍵字搜尋，例如：台積電、聯準會、升息。填了會忽略 `newsCategory`，改用關鍵字搜尋。單次最多 **50** 個。          |
| `dateFrom`     | string   |       選填       |     —      | 只保留此日期（含）之後發布的新聞，格式 `YYYY-MM-DD`。僅 `news` 模式有效。                                                |
| `dateTo`       | string   |       選填       |     —      | 只保留此日期（含）之前發布的新聞，格式 `YYYY-MM-DD`。僅 `news` 模式有效。                                                |
| `stockCodes`   | string\[] | `quote` 模式必填 |     —      | 台股上市個股代號，例如 `2330`（台積電）、`2454`（聯發科）、`2317`（鴻海）。單次最多 **100** 檔。                         |
| `bulkInput`    | string   |       選填       |     —      | **一行一個**，按 Enter 換行，不要加引號或逗號。`news` 模式當關鍵字、`quote` 模式當股票代號，執行時自動併入上面對應欄位。 |
| `maxItems`     | integer  |       選填       |    `50`    | 每個分類/關鍵字最多抓幾筆（`news` 模式，1-500）。`quote` 模式不受此限，依股票代號數量而定。                              |

***

### 範例

**📰 分類新聞（台股新聞）**

```json
{
    "mode": "news",
    "newsCategory": "tw_stock",
    "maxItems": 15
}
```

**🔎 關鍵字搜尋新聞**

```json
{
    "mode": "news",
    "keywords": ["台積電"],
    "maxItems": 10
}
```

**📈 個股即時報價**

```json
{
    "mode": "quote",
    "stockCodes": ["2330", "2454", "2317"]
}
```

***

### 幾個要注意的地方

- **只抓公開資料**。cnyes 新聞列表與個股報價端點皆為公開 JSON API，不需要登入、不需要 cnyes 帳號，也不會存取任何需要驗證才看得到的內容。
- **不用登入 / 不用 API token**。填好 input 就能跑，沒有任何金鑰要設定。
- **走 cnyes 公開 JSON API，不開瀏覽器**。全程用 `CheerioCrawler` 打 `api.cnyes.com` / `ws.api.cnyes.com` 端點，比 Playwright 省一大截 compute 成本。
- **對站方友善**。每個 domain 併發數 ≤5，遇到失敗會用指數退避重試最多 3 次，不會對 cnyes 伺服器狂發請求。
- **財經新聞 + 即時股價一套抓，適合輿情分析**。`news` 模式的 `related_stocks` 標籤可以跟 `quote` 模式的股價資料交叉比對，做財經輿情與量化 dashboard 的原始資料源。
- **同一新聞若命中分類與關鍵字搜尋，會分別各出一列（依查詢計費）**。`source_query` 會標明這筆資料是哪個分類或關鍵字抓到的。

***

### 常見問題

**Q: 股票代號怎麼給？**
直接給台股上市代號的數字即可，例如 `2330`、`2454`。爬蟲會自動正規化成 cnyes 內部格式 `TWS:2330:STOCK`；已經是這個格式的輸入也可以直接貼。目前僅支援台股上市（v1.1 規劃上櫃 TWO、指數、ETF）。

**Q: 為什麼沒有成交量（volume）？**
cnyes 即時報價端點回傳的是數字代碼（如 `6`=最新價、`11`=漲跌），本次實測驗證了最新價、漲跌、漲跌幅、最高、最低、52 週高低等碼，但成交量對應的碼尚未逐一驗證，為避免猜錯欄位造成誤導，v1.0 一律回 `null`，成交量支援規劃在 v1.1。

**Q: 費用怎麼算？**
每次 Run 啟動收一次 `apify-actor-start`（$0.005）；`news` 模式每筆新聞收 `search-listing`（$0.002）；`quote` 模式每筆報價收 `product-detail`（$0.008）。都是資料成功寫入 dataset 後才收費，Run log 會印出實際收費筆數。

**Q: 抓不到資料怎麼辦？**
先確認新聞分類代碼或關鍵字有沒有打錯字；`quote` 模式則確認股票代號是否為台股上市代號。爬蟲連續 5 次拿不到新資料就會自己停並在 log 寫原因，不會空轉燒錢。

***

### 部署

```bash
apify login              # 首次:貼上 Apify token(不會寫進 repo)
apify push               # 建置並上傳到 Apify Store
```

上架後在 Apify Console 的 Monetization 設定 PPE 事件單價：
`apify-actor-start` $0.005、`search-listing` $0.002、`product-detail` $0.008。

***

### 免責聲明

本爬蟲只收集鉅亨網（cnyes.com）**公開可見**的財經新聞與股價資料，資料僅供研究與個人用途使用，不用於任何未經授權的商業轉售。使用前請自行確認符合 cnyes 服務條款與當地法規。所有財經資訊、股價數據**不構成任何投資建議**，投資決策請自行判斷並承擔風險。對於資料的正確性、即時性或完整性，本 Actor 不做任何保證，股價與新聞內容請以 cnyes 官網當下顯示為準。

***

*鉅亨網 爬蟲、cnyes API、台股報價、財經新聞、股價數據、財經輿情*

# Actor input Schema

## `mode` (type: `string`):

要抓什麼?選一個模式,填下面對應欄位就好。

## `newsCategory` (type: `string`):

財經新聞分類代碼,常見:tw\_stock(台股)、headline(焦點)、tw\_money(理財)。未填 keywords 時預設抓 tw\_stock。

## `keywords` (type: `array`):

財經新聞關鍵字搜尋,例如:台積電、聯準會、升息。填了這裡就會忽略新聞分類,改用關鍵字搜尋。

## `dateFrom` (type: `string`):

只保留此日期(含)之後發布的新聞,格式 YYYY-MM-DD,例如 2026-07-01。僅新聞模式有效,留空表示不限。

## `dateTo` (type: `string`):

只保留此日期(含)之前發布的新聞,格式 YYYY-MM-DD。僅新聞模式有效,留空表示不限。

## `stockCodes` (type: `array`):

台股上市個股代號,例如 2330(台積電)、2454(聯發科)、2317(鴻海)。報價模式用這個,單次最多 100 檔。

## `bulkInput` (type: `string`):

**一行一個**,按 Enter 換行,不要加引號或逗號。新聞模式當關鍵字、報價模式當股票代號,執行時自動併入上面對應欄位。從 Google Sheet / Excel 複製一整欄貼進來最快。

## `maxItems` (type: `integer`):

每個分類/關鍵字最多抓幾筆(新聞模式)。越多費用越高。報價模式不受此限(依股票代號數量)。

## `proxyConfiguration` (type: `object`):

cnyes 對 datacenter 請求友善,預設不用 proxy 即可運作。只有大量抓取遇到被擋時才建議開啟。

## Actor input object example

```json
{
  "mode": "news",
  "newsCategory": "tw_stock",
  "maxItems": 50,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "news",
    "newsCategory": "tw_stock"
};

// Run the Actor and wait for it to finish
const run = await client.actor("claude_code_reviewer/cnyes-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "mode": "news",
    "newsCategory": "tw_stock",
}

# Run the Actor and wait for it to finish
run = client.actor("claude_code_reviewer/cnyes-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "news",
  "newsCategory": "tw_stock"
}' |
apify call claude_code_reviewer/cnyes-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,claude_code_reviewer/cnyes-scraper"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/emv8umYdKYx03NCXd/builds/gZvoEeP0gkoGWHZrH/openapi.json
