通用AI驱动的网页抓取工具,适用于任何平台。从Instagram、Facebook、TikTok、YouTube、LinkedIn、X/Twitter、Google Maps、Google搜索、Google Trends、Reddit、Airbnb、Yelp等15+个平台抓取数据。可用于潜在客户开发、品牌监控、竞争对手分析、网红发现、趋势研究、内容分析、受众分析、评论分析、SEO情报、招聘或任何数据提取任务。
通用网页抓取器
通过Apify CLI从15+个平台的约100个Actor进行AI驱动的数据提取。
每个apify命令的规则:
- 传递
--json以获得机器可读的输出(在CLI版本间稳定)。 - 传递
--user-agent apify-agent-skills/apify-ultimate-scraper用于遥测归属。 - 使用
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=...)
生成令牌: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模式并检查注意事项
动态获取输入模式:
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之前请阅读它。






