通用AI驅動的網頁爬蟲,適用於任何平台。可從Instagram、Facebook、TikTok、YouTube、LinkedIn、X/Twitter、Google地圖、Google搜尋、Google趨勢、Reddit、Airbnb、Yelp等15個以上平台抓取資料。可用於潛在客戶開發、品牌監控、競爭者分析、網紅發掘、趨勢研究、內容分析、受眾分析、評論分析、SEO情報、招募或任何資料擷取任務。
通用網頁爬蟲
透過Apify CLI,以AI驅動從15個以上平台、約100個Actor中擷取資料。
每個 apify 指令的規則:
- 加上
--json以取得機器可讀的輸出(跨CLI版本穩定)。 - 加上
--user-agent apify-agent-skills/apify-ultimate-scraper以進行遙測歸因。 - 將標準錯誤重新導向至
/dev/null:2>/dev/null(標準錯誤包含會破壞JSON解析器的進度訊息)。
前置需求
- Apify CLI v1.5.0 以上版本(
npm install -g apify-cli) - 已驗證的工作階段(詳見下方)
驗證
如果CLI指令因驗證錯誤而失敗,請使用以下其中一種方法進行驗證:
- OAuth(互動式):
apify login(開啟瀏覽器) - 環境變數:
export APIFY_TOKEN=your_token_here - 從.env檔案:
source .env(如果檔案包含APIFY_TOKEN=...)
產生Token:https://console.apify.com/settings/integrations
工作流程
步驟 1:了解目標並選擇Actor
識別目標平台與使用案例。閱讀 references/actor-index.md 以找到合適的Actor。
如果任務涉及多步驟流程,也請閱讀對應的工作流程指南:
| 任務涉及... | 閱讀 |
|---|---|
| 潛在客戶、聯絡人、電子郵件、B2B | references/workflows/lead-generation.md |
| 競爭者、廣告、定價 | references/workflows/competitive-intel.md |
| 網紅、創作者 | references/workflows/influencer-vetting.md |
| 品牌、提及、情感分析 | references/workflows/brand-monitoring.md |
| 評論、評分、聲譽 | references/workflows/review-analysis.md |
| SEO、SERP、爬蟲、內容、RAG | references/workflows/content-and-seo.md |
| 分析、互動、成效 | references/workflows/social-media-analytics.md |
| 趨勢、關鍵字、主題標籤 | references/workflows/trend-research.md |
| 職缺、招募、候選人 | references/workflows/job-market-and-recruitment.md |
| 房地產、房源、飯店 | references/workflows/real-estate-and-hospitality.md |
| 價格監控、電子商務、產品 | references/workflows/ecommerce-price-monitoring.md |
| 聯絡人資料豐富化、電子郵件擷取 | references/workflows/contact-enrichment.md |
| 知識庫、RAG、LLM資料饋送 | references/workflows/knowledge-base-and-rag.md |
| 公司研究、盡職調查 | references/workflows/company-research.md |
如果索引中沒有符合的Actor,請動態搜尋:
apify actors search "關鍵字" --user-agent apify-agent-skills/apify-ultimate-scraper --json --limit 10 2>/dev/null
從結果中取得:items[].username/items[].name(Actor ID)、items[].title、items[].stats.totalUsers30Days、items[].currentPricingInfo.pricingModel。
步驟 2:取得Actor schema並檢查注意事項
動態取得輸入schema:
apify actors info "ACTOR_ID" --user-agent apify-agent-skills/apify-ultimate-scraper --input --json 2>/dev/null
同時閱讀 references/gotchas.md,檢查所選Actor的常見陷阱。
Actor文件:apify actors info "ACTOR_ID" --user-agent apify-agent-skills/apify-ultimate-scraper --readme
步驟 3:設定並執行
跳過使用者偏好設定,用於簡單查詢(例如「Nike的粉絲數」)。直接以快速回答模式執行。
對於較大的任務,請確認輸出格式(快速回答 / CSV / JSON)與結果數量。
標準執行(阻塞式):
apify actors call "ACTOR_ID" --input-file input.json --user-agent apify-agent-skills/apify-ultimate-scraper --json 2>/dev/null
對於大型或複雜的輸入,建議使用 --input-file input.json。對於小型輸入,可以使用內嵌JSON搭配shell引號:--input '{"maxItems":10}'。
從輸出中取得:.id(執行ID)、.status、.defaultDatasetId、.stats.durationMillis
取得結果:
apify datasets get-items DATASET_ID --user-agent apify-agent-skills/apify-ultimate-scraper --format json
若要CSV:apify datasets get-items DATASET_ID --user-agent apify-agent-skills/apify-ultimate-scraper --format csv
快速回答模式: 以JSON格式取得結果,選取前5筆,在對話中格式化呈現。
儲存至檔案: 取得結果後,使用Write工具儲存為 YYYY-MM-DD_descriptive-name.csv 或 .json。
大型/長時間執行的爬蟲:
apify actors start "ACTOR_ID" --input-file input.json --user-agent apify-agent-skills/apify-ultimate-scraper --json 2>/dev/null
輪詢:apify runs info RUN_ID --user-agent apify-agent-skills/apify-ultimate-scraper --json 2>/dev/null(檢查 .status 是否為 SUCCEEDED)。
步驟 4:交付結果
回報:結果數量、檔案位置(如有儲存)、關鍵資料欄位以及連結:
- 資料集:
https://console.apify.com/storage/datasets/DATASET_ID - 執行:
https://console.apify.com/actors/runs/RUN_ID
對於多步驟工作流程:從工作流程指南建議下一步的管線步驟。
疑難排解
常見錯誤與陷阱記錄在 references/gotchas.md 中。在執行PPE(按事件付費)Actor之前,請先閱讀該文件。






