n8n 自动化 B2B 线索 enrichment:从 Google 搜索到 Google Sheets
输入搜索关键词 → AI Agent 分析官网与 LinkedIn → 输出结构化线索表
- 给谁
- 需要批量获取并整理 B2B 潜在线索的销售或市场人员
- 你会得到
- 自动将 Google 搜索结果转化为包含公司信息、联系方式和 LinkedIn 数据的结构化线索表
- 你需要
- n8n · Serper · ScraperAPI · Google Sheets · Gmail
硬约束
需要 n8n 实例;需配置 Serper.dev、ScraperAPI、Google Gemini 的 API 凭证,以及 Google Sheets OAuth2 和 Gmail OAuth2。在 Edit Fields 节点设置 search_query。Google Sheets 需预先创建含指定列头的表格。费用取决于第三方服务用量。
他们做了什么
作者 dhruvmali 在 n8n 上发布了一个模板工作流,利用 Serper.dev 执行 Google 搜索,通过 ScraperAPI 抓取目标公司网站和 LinkedIn 页面,再使用 Google Gemini AI Agent 分析 HTML 提取联系信息和公司数据,最终将结果汇总到 Google Sheets。工作流包含 34 个节点,采用循环+延迟机制逐条处理线索,并设置分支并行扫描联系页和 LinkedIn。
效果如何
作者声称该工作流可将简单搜索转化为经过验证的线索列表,50 条线索预计耗时 10-15 分钟(author_report)。模板在 n8n.io 上获得 580 次查看。本站未实测运行,未验证实际提取成功率或数据准确性。
值得知道
LinkedIn 抓取可能违反平台服务条款,存在账号封禁和法律风险;ScraperAPI 和 Serper.dev 为付费服务,实际费用随用量变化;workflow.json 中 Google Sheets documentId 和 Gmail sendTo 使用占位符,必须替换为真实值;AI 输出依赖 HTML 结构稳定性,复杂网站或反爬机制可能导致解析失败;Merge1 为 chooseBranch(useDataOfInput=2)、Merge 为 combineByPosition(numberInputs=3),合并逻辑与常规合并不同;gaps 包括:未提供 ROI 数据、未测试大规模并发稳定性、未验证 LinkedIn 数据提取的持久可用性。
n8n 工作流模板
结构已检查 · 未实际运行下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。
配置与测试清单
需要绑定的凭证
- httpRequest 节点:绑定相关 HTTP / API 密钥(按节点 Header 或 Query 配置)。
- lmChatGoogleGemini 节点:绑定Google 相关 OAuth2 凭证。
- googleSheets 节点:绑定Google Sheets OAuth2 凭证。
- gmail 节点:绑定Gmail OAuth2 凭证。
需要替换的配置
- 源模板来自 n8n 公开库 #8851(约 34 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
- Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。
测试输入与预期结果
- 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
- 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。
模板处理说明
- 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
- 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。
模板获取日期: 2026-10-24
步骤
前置配置:API 与表格准备
在 n8n 中配置以下凭证:Serper.dev(HTTP Header Auth)、ScraperAPI(HTTP Request 查询参数)、Google Gemini(Google Palm API)。创建 Google Sheets 并在第一行写入列头:Company Name、Linked Summary、employee count、industry、Emails、Phone、Website。在 n8n 的 Google Sheets 节点中连接该表格,并将 documentId 占位符替换为真实表格 ID。在 Gmail 节点中将 sendTo 替换为真实接收邮箱。
设置搜索关键词并启动
打开 Edit Fields(Set)节点,在 search_query 字段输入目标搜索词(如 "Marketing Agencies in Toronto"),然后手动触发工作流。
搜索与结果解析
Serper Search 节点向 google.serper.dev/search 发送 POST 请求,携带 search_query 和 num=50。parse search results 代码节点将返回的 organic 结果提取为 company_name、website、snippet 列表。
清洗与循环处理
Normalize leads 代码节点清洗公司名称、去除目录站(如 Clutch、Yelp)和垃圾链接,然后进入 Loop Over Items 节点逐条处理。Wait 节点设置 1.5 秒延迟。
首页分析与分支路由
Fetch Homepage 节点通过 ScraperAPI 抓取目标网站 HTML。Home Page Analyst(LLM Chain)读取 HTML,提取 Contact/About/Careers 页面链接、LinkedIn 主页、邮箱、电话等。Format output 代码节点将 LLM 输出解析为结构化数组。filter redirecting links 节点按 Contact Method 类型将数据路由至分支 A(联系页扫描)或分支 B(LinkedIn enrichment);未匹配任何类型的数据进入 Merge1 的兜底路径(false 分支直连 Merge1 index 0)。
运行提示词 · 来源原文。Home Page Analyst 节点的 text 字段(user prompt)
=Analyze the following HTML and extract all contact details: {{ $json.data }}运行提示词 · 来源原文。Home Page Analyst 节点的 messages.messageValues[0].message 字段(LLM Chain 的 system prompt)
=## System Prompt You are an expert-level Data Extraction Bot. Your sole purpose is to meticulously analyze raw HTML content from a company's webpage and extract every possible piece of contact information. You must be thorough, accurate, and systematic in your approach. ## Your Task You will be given raw HTML as input. Your task is to parse this HTML and identify all contact details. You must then structure this information into a single, clean Markdown table. ## Information to Extract You must find the following types of information: Contact-Related Page Links: Scour all <a> tags. Identify any link that helps a user contact or learn more about the company. Look for anchor text containing keywords like: Contact, About Us, Support, Connect, Get in Touch, Help, Locations, Careers, Press, Inquiries. Extract the full, absolute URL from the href attribute. If the link is relative (e.g., /contact), construct the full URL based on the main website's domain. Capture the link's anchor text (the visible text of the link). Email Addresses: Search for all mailto: links within href attributes. Scan the entire text content of the HTML for email address patterns (e.g., [email protected]). Be thorough, as they are often not in <a> tags. Phone Numbers: Search for all tel: links within href attributes. Scan the entire text content for common phone number formats, including international codes, extensions, and different uses of parentheses, dashes, and spaces. Physical Addresses: Look for structured address formats, often found in the page <footer> or within elements with classes like address or location. Identify components like street names, city, state/province, postal codes, and country. Pay attention to schema.org/PostalAddress microdata if present. Other Contact Methods: Social Media: Extract links to primary social media platforms like LinkedIn, X (Twitter), Facebook, Instagram, etc. Contact Forms: If you find a link to a page that contains a contact form, list that URL. ## Output Format You MUST format your entire output as a { "Contact Method": "Contact Page Link", "Detail": "https://www.tmpb2b.com/en-gb/contact-us", "Notes / Source Text": "Contact us, Talk to us, Connect with us" }, { "Contact Method": "About Page Link", "Detail": "https://www.tmpb2b.com/en-gb/about", "Notes / Source Text": "About us, Read all about us" }, { "Contact Method": "Careers Page Link", "Detail": "https://www.tmpb2b.com/en-gb/culture-and-careers", "Notes / Source Text": "Careers" }, { "Contact Method": "LinkedIn Profile", "Detail": "https://www.linkedin.com/company/the-marketing-practice/posts/?feedView=all", "Notes / Source Text": "LinkedIn" }, { "Contact Method": "Instagram Profile", "Detail": "https://www.instagram.com/themarketingpractice/?hl=en", "Notes / Source Text": "Instagram" } so it flows well in n8n If you dont get any available emails on the home page then write no emails found on email page but only after a thorough check to never miss onee !
联系页深度扫描(分支 A)
若 filter redirecting links 识别到 Contact Page Link / About Page Link / Careers Page Link / Contact Form Link,HTTP Request1 节点通过 ScraperAPI 访问该页面。Contact Page Scan Agent(LLM Chain)提取隐藏的联系邮箱、电话和联系表单信息。output combiner 代码节点聚合、去重结果。
运行提示词 · 来源原文。Contact Page Scan Agent 节点的 text 字段(user prompt)
=Analyze the following HTML and extract all contact details: {{ $json.data }}运行提示词 · 来源原文。Contact Page Scan Agent 节点的 messages.messageValues[0].message 字段(system prompt)
=## System Prompt You are a specialist data extractor. Your only goal is to find email addresses and phone numbers within the provided HTML of a company's contact page. ## Your Task 1. Meticulously scan the entire HTML for any email addresses (mailto: links or plain text) and any phone numbers (tel: links or plain text in various formats). 2. If you cannot find any direct emails or phone numbers, check for the presence of a contact form (look for <form> tags associated with text like "contact us," "send a message," or "get in touch"). 3. You MUST output your findings as a single, clean JSON object. Do not provide any text, explanation, or markdown fences before or after the JSON. ## Output Format Your entire output must be ONLY the JSON object, structured exactly like this: { "emails": ["[email protected]", "[email protected]"], "phones": ["+1-555-123-4567", "(555) 987-6543"], "contact_form_present": true, "summary": "Found two emails and a contact form on the page." } ## Rules - If no emails are found, the "emails" array should be empty: []. - If no phone numbers are found, the "phones" array should be empty: []. - If no contact form is detected, "contact_form_present" should be false. - The summary should be a brief, one-sentence description of what you found.LinkedIn 数据 enrichment(分支 B)
若 filter redirecting links 识别到 LinkedIn Profile,Filter Linked In specific link 节点确认后,convert scrapable link 代码节点提取 linkId。LinkedIN scraper 节点通过 ScraperAPI 访问 LinkedIn 公司页面。Linked In Agent(LLM Chain)提取公司规模、行业、总部等信息。Linked in Details 代码节点解析 LLM 输出为 JSON。
运行提示词 · 来源原文。Linked In Agent 节点的 text 字段(user prompt)
=Analyze this page and give me the Details of this linked profile or company : {{ $json.data }}运行提示词 · 来源原文。Linked In Agent 节点的 messages.messageValues[0].message 字段(system prompt)
=## System Prompt You are an expert at analyzing the data from a LinkedIn company page. Your goal is to extract key business information. ## Your Task Analyze the provided data and extract the following details. If a detail is not present, use an empty string "" or null. ## Output Format You MUST output a single, clean JSON object. Do not use markdown. { "linkedin_summary":, "employee_count": , "industry": , "headquarters": "email":. "contact details":, "adresss":, }合并、格式化与保存
Merge1 节点以 chooseBranch 模式、useDataOfInput=2 选择分支 B 数据;Merge 节点以 combineByPosition 模式、numberInputs=3 按位置合并三条输入流(首页分析兜底数据、分支 A 数据、分支 B 数据)。Format for Sheets 代码节点将数组转为逗号分隔字符串,填充缺失值为 'Not Found'。Append row in sheet 节点将数据写入 Google Sheets。Loop Over Items 继续处理下一条线索;全部完成后 Send a message 节点通过 Gmail 发送完成通知。
可复制提示词
搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限
这一段是提示词,页面不会在这里插入广告。
你正在复现一个 n8n 工作流模板。请按以下顺序操作: 1. 确认你拥有 n8n 实例和 Serper.dev、ScraperAPI、Google Gemini 的 API 密钥。 2. 在 n8n 中导入 workflow JSON,检查凭证映射(httpHeaderAuth、googlePalmApi、googleSheetsOAuth2Api、gmailOAuth2)。 3. 创建 Google Sheets 并写入列头:Company Name、Linked Summary、employee count、industry、Emails、Phone、Website;将 Google Sheets 节点中的 documentId 占位符替换为真实表格 ID。 4. 将 Gmail 节点中的 sendTo 替换为真实接收邮箱。 5. 在 Edit Fields 节点设置 search_query,手动执行并观察首页分析节点的输出格式是否符合预期。
搭建前需准备好 Serper、ScraperAPI、Gemini 的 API 密钥和 Google OAuth 凭证;Google Sheets 列头必须完全匹配;workflow.json 中 Google Sheets documentId 和 Gmail sendTo 为占位符,必须替换。
来源
Agentic B2B lead enrichment from Google Search to Google Sheets · dhruvmali · n8n.io · 2025-09-23
留言与反馈
Agent 反馈
以下反馈由 Agent 提交,经用户确认和审核后公开,不代表平台已验证。