n8n 是一种流行的无代码工作流程自动化工具,但它不包含本机 Web 搜索节点。添加搜索仅需要一个 HTTP 请求节点和五分钟的配置。本教程逐步完成设置,展示如何解析结果,并包括三个工作流程模板:内容研究、竞争对手监控和潜在客户丰富。费用:每次通过 Scavio 搜索 0.005 美元。
前置条件
- 安装了 n8n(自托管或 n8n.cloud)
- 来自 scavio.dev 的 Scavio API 密钥
- 基本熟悉 n8n 节点
操作指南
步骤 1: 添加HTTP请求节点进行搜索
配置 HTTP 请求节点以调用 Scavio 搜索 API。这是网络搜索所需的唯一节点。
Python
# n8n HTTP Request Node Configuration:
#
# 1. Add an HTTP Request node to your workflow
# 2. Configure it:
# Method: POST
# URL: https://api.scavio.dev/api/v1/search
# Authentication: None
# Send Headers: ON
# Header 1: x-api-key = {{$env.SCAVIO_API_KEY}}
# Header 2: Content-Type = application/json
# Send Body: ON
# Body Content Type: JSON
# Body Parameters:
# query = {{$json.search_query}} (or hardcode a string)
# country_code = us
# num_results = 10
#
# 3. Test it by clicking 'Execute Node'
# Python equivalent for testing:
import requests, os
resp = requests.post('https://api.scavio.dev/api/v1/search',
headers={'x-api-key': os.environ['SCAVIO_API_KEY'],
'Content-Type': 'application/json'},
json={'query': 'n8n workflow automation 2026',
'country_code': 'us', 'num_results': 5})
results = resp.json().get('organic_results', [])
print(f'{len(results)} results returned')
for r in results:
print(f' {r["title"][:50]}')步骤 2: 解析 n8n 中的搜索结果
在 HTTP 请求后添加 Set 节点或 Function 节点,以从搜索响应中提取所需的字段。
Python
# n8n Function Node to parse results:
# (Place after the HTTP Request node)
#
# const results = $input.first().json.organic_results || [];
# return results.map(r => ({
# json: {
# title: r.title,
# url: r.link,
# snippet: r.snippet || '',
# domain: new URL(r.link).hostname
# }
# }));
# Python equivalent:
def parse_results(api_response: dict) -> list:
results = api_response.get('organic_results', [])
return [{
'title': r['title'],
'url': r['link'],
'snippet': r.get('snippet', ''),
'domain': r['link'].split('/')[2] if '/' in r['link'] else ''
} for r in results]
data = resp.json()
parsed = parse_results(data)
for r in parsed[:3]:
print(f'{r["title"]}: {r["domain"]}')步骤 3: 三个即用型工作流程模板
将搜索节点连接到不同的触发器和下游节点以实现常见的自动化模式。
Python
# Template 1: Content Research (Cron -> Search -> Google Sheets)
# Trigger: Schedule (daily at 9am)
# Search query: 'latest {your_topic} news 2026'
# Output: Append results to Google Sheets
# Template 2: Competitor Monitor (Cron -> Search -> Slack)
# Trigger: Schedule (every 6 hours)
# Search query: 'site:{competitor.com} new'
# Output: Send new pages to Slack channel
# Template 3: Lead Enrichment (Webhook -> Search -> CRM)
# Trigger: Webhook (receives company name)
# Search query: '{company_name} news funding 2026'
# Output: Update CRM record with enrichment data
import requests, os
SCAVIO_KEY = os.environ['SCAVIO_API_KEY']
def search(query):
resp = requests.post('https://api.scavio.dev/api/v1/search',
headers={'x-api-key': SCAVIO_KEY, 'Content-Type': 'application/json'},
json={'query': query, 'country_code': 'us', 'num_results': 5})
return resp.json().get('organic_results', [])
# Template 1: Daily content research
results = search('AI agent frameworks news 2026')
print(f'Content research: {len(results)} articles found')
# Template 2: Competitor monitoring
results = search('site:competitor.com new features')
print(f'Competitor updates: {len(results)} new pages')
# Template 3: Lead enrichment
results = search('Acme Corp funding news 2026')
print(f'Lead enrichment: {len(results)} results')
print(f'\nTotal cost: 3 searches = $0.015')
print(f'Monthly at 4x/day: $1.80')Python 示例
Python
import requests, os
SCAVIO_KEY = os.environ['SCAVIO_API_KEY']
def search(query, count=5):
resp = requests.post('https://api.scavio.dev/api/v1/search',
headers={'x-api-key': SCAVIO_KEY, 'Content-Type': 'application/json'},
json={'query': query, 'country_code': 'us', 'num_results': count})
return [{'title': r['title'], 'url': r['link'], 'snippet': r.get('snippet', '')}
for r in resp.json().get('organic_results', [])]
# Same query your n8n HTTP Request node would make
results = search('n8n workflow automation 2026')
for r in results:
print(f'{r["title"]}: {r["url"]}')
print(f'Cost: $0.005')JavaScript 示例
JavaScript
const SCAVIO_KEY = process.env.SCAVIO_API_KEY;
async function search(query, count = 5) {
const resp = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST',
headers: { 'x-api-key': SCAVIO_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({ query, country_code: 'us', num_results: count })
});
return (await resp.json()).organic_results?.map(r => ({
title: r.title, url: r.link, snippet: r.snippet || ''
})) || [];
}
// Same query your n8n node would make
search('n8n workflow automation 2026').then(r => r.forEach(x => console.log(x.title)));预期输出
JSON
5 results returned
n8n Workflow Automation Platform - Getting Started
Best n8n Workflows for 2026 - Community Templates
How to Automate Anything with n8n
Content research: 5 articles found
Competitor updates: 3 new pages
Lead enrichment: 5 results
Total cost: 3 searches = $0.015
Monthly at 4x/day: $1.80