模板v08/02 - Facebook广告库到亚马逊爬虫
高级
这是一个Market Research领域的自动化工作流,包含 24 个节点。主要使用 If, Set, Code, Limit, Filter 等节点。 使用 Apify 爬虫自动在亚马逊上搜索 Facebook 广告产品
前置要求
- •可能需要目标 API 的认证凭证
- •Google Sheets API 凭证
- •OpenAI API Key
分类
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "CNlX00MuSiOtJXQG",
"meta": {
"instanceId": "de7078f0855f0e960f39df9530d5e9762516cd1dfa98b13db725c63cf3f45fe9",
"templateCredsSetupCompleted": true
},
"name": "模板v08/02 - Facebook广告库到亚马逊爬虫",
"tags": [
{
"id": "Ki43TEjHd7EDcykZ",
"name": "My Templates",
"createdAt": "2025-07-31T13:58:06.976Z",
"updatedAt": "2025-07-31T13:58:06.976Z"
}
],
"nodes": [
{
"id": "8ea1eb6a-9814-4935-82f0-dbe7fbe1b318",
"name": "手动触发器",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-1632,
32
],
"parameters": {},
"typeVersion": 1
},
{
"id": "bb8871d1-2208-406d-9210-e9b4c95d9cc3",
"name": "遍历项目",
"type": "n8n-nodes-base.splitInBatches",
"onError": "continueRegularOutput",
"position": [
-672,
-32
],
"parameters": {
"options": {}
},
"typeVersion": 3
},
{
"id": "3a4ad496-8165-4987-aee1-f804fb8d35fd",
"name": "运行FB库执行器",
"type": "n8n-nodes-base.httpRequest",
"position": [
-1408,
32
],
"parameters": {
"method": "POST",
"options": {},
"jsonBody": "{\n \"count\": 10,\n \"scrapeAdDetails\": true,\n \"scrapePageAds.activeStatus\": \"all\",\n \"urls\": [\n {\n \"url\": \"https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&is_targeted_country=false&media_type=all&q=Wireless%20Mouse&search_type=keyword_unordered&source=fb-logo\",\n \"method\": \"GET\"\n }\n ]\n}",
"sendBody": true,
"specifyBody": "json"
},
"typeVersion": 4.2
},
{
"id": "7d6752e1-b469-4ed2-a651-bd9be05cc80a",
"name": "获取执行器的爬取内容",
"type": "n8n-nodes-base.httpRequest",
"position": [
-1184,
32
],
"parameters": {
"options": {}
},
"typeVersion": 4.2
},
{
"id": "77462d23-50ef-4990-94ac-bce340f8ec93",
"name": "爬取网站内容",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueRegularOutput",
"position": [
-384,
112
],
"parameters": {
"url": "={{ $json.snapshot.caption }}",
"options": {}
},
"typeVersion": 4.2,
"alwaysOutputData": true
},
{
"id": "a9849513-c2bd-42b4-97bf-d9d56a52c463",
"name": "转换为纯文本",
"type": "n8n-nodes-base.code",
"onError": "continueRegularOutput",
"position": [
-160,
112
],
"parameters": {
"jsCode": "// HTML to Plain Text Converter for n8n Code Node\n// This code takes HTML content and converts it to clean plain text\n\n// Get the HTML content from the previous node\n// Adjust the field name based on your input data structure\nconst htmlContent = $input.first().json.data\n\nif (!htmlContent) {\n return [{ json: { error: \"No HTML content found in input\" } }];\n}\n\n// Function to strip HTML tags and decode HTML entities\nfunction htmlToPlainText(html) {\n let text = html;\n \n // Remove script and style elements completely\n text = text.replace(/<script[^>]*>[\\s\\S]*?<\\/script>/gi, '');\n text = text.replace(/<style[^>]*>[\\s\\S]*?<\\/style>/gi, '');\n \n // Replace common block elements with line breaks\n text = text.replace(/<\\/?(div|p|br|h[1-6]|li|tr)[^>]*>/gi, '\\n');\n \n // Replace list items with bullet points\n text = text.replace(/<li[^>]*>/gi, '• ');\n \n // Remove all remaining HTML tags\n text = text.replace(/<[^>]*>/g, '');\n \n // Decode common HTML entities\n const entityMap = {\n '&': '&',\n '<': '<',\n '>': '>',\n '"': '\"',\n ''': \"'\",\n ''': \"'\",\n ' ': ' ',\n '©': '©',\n '®': '®',\n '™': '™',\n '…': '...',\n '—': '—',\n '–': '–'\n };\n \n for (const [entity, char] of Object.entries(entityMap)) {\n text = text.replace(new RegExp(entity, 'g'), char);\n }\n \n // Decode numeric HTML entities (e.g., {)\n text = text.replace(/&#(\\d+);/g, (match, dec) => {\n return String.fromCharCode(dec);\n });\n \n // Decode hex HTML entities (e.g., )\n text = text.replace(/&#x([0-9A-Fa-f]+);/g, (match, hex) => {\n return String.fromCharCode(parseInt(hex, 16));\n });\n \n // Clean up whitespace\n text = text.replace(/\\n\\s*\\n/g, '\\n\\n'); // Remove excessive line breaks\n text = text.replace(/[ \\t]+/g, ' '); // Replace multiple spaces/tabs with single space\n text = text.trim(); // Remove leading/trailing whitespace\n \n return text;\n}\n\ntry {\n const plainText = htmlToPlainText(htmlContent);\n \n return [{\n json: {\n originalHtml: htmlContent,\n plainText: plainText,\n characterCount: plainText.length,\n wordCount: plainText.split(/\\s+/).filter(word => word.length > 0).length,\n success: true\n }\n }];\n \n} catch (error) {\n return [{\n json: {\n error: `Failed to convert HTML to text: ${error.message}`,\n originalHtml: htmlContent,\n success: false\n }\n }];\n}"
},
"typeVersion": 2,
"alwaysOutputData": true
},
{
"id": "589ecbf9-917f-470e-9ade-5553b453421f",
"name": "运行亚马逊搜索执行器",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueRegularOutput",
"position": [
768,
128
],
"parameters": {
"method": "POST",
"options": {},
"jsonBody": "={\n \"input\": [\n {\n \"keyword\": \"{{ $json.message.content }}\",\n \"domainCode\": \"com\",\n \"sortBy\": \"recent\",\n \"maxPages\": 1,\n \"category\": \"aps\"\n }\n ]\n}",
"sendBody": true,
"specifyBody": "json"
},
"typeVersion": 4.2,
"alwaysOutputData": true
},
{
"id": "54bfb46b-4972-4cd0-a471-daf64f4f8aa2",
"name": "编辑字段1",
"type": "n8n-nodes-base.set",
"onError": "continueRegularOutput",
"position": [
1216,
128
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "d4bca713-ea0f-496b-935a-c7e03939c993",
"name": "amazonURL",
"type": "string",
"value": "={{ 'https://www.amazon.com'.concat($json.dpUrl) }}"
},
{
"id": "aa404d43-dd49-4836-be25-9546b764c44e",
"name": "productTitle",
"type": "string",
"value": "={{ $json.productDescription }}"
},
{
"id": "7e5ba88b-fd1b-44a3-999b-25fecc0dfdf1",
"name": "price",
"type": "number",
"value": "={{ $json.price }}"
},
{
"id": "756647b3-5893-498a-9233-afc4a7e25023",
"name": "productRating",
"type": "number",
"value": "={{ $json.productRating.slice(0,3) }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "657bf062-6adb-4b04-b76b-ecec8c11ff33",
"name": "过滤器",
"type": "n8n-nodes-base.filter",
"onError": "continueRegularOutput",
"position": [
1440,
128
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "05637cd3-af97-4c9a-908e-ce53f5d89d2a",
"operator": {
"type": "number",
"operation": "gte"
},
"leftValue": "={{ $json.productRating }}",
"rightValue": 4.3
}
]
}
},
"typeVersion": 2.2,
"alwaysOutputData": true
},
{
"id": "c4e12fad-a045-4e97-a6c0-da1eecf92e27",
"name": "限制",
"type": "n8n-nodes-base.limit",
"position": [
1792,
128
],
"parameters": {},
"typeVersion": 1,
"alwaysOutputData": true
},
{
"id": "ecd58583-9264-493c-8f9c-d1806efcae5a",
"name": "保存项目",
"type": "n8n-nodes-base.set",
"position": [
2016,
128
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "c035dbc4-96c7-41f3-abc4-865026954816",
"name": "amazonURL",
"type": "string",
"value": "={{ $json.amazonURL }}"
},
{
"id": "4eed2bbc-41f3-4deb-8704-a121180645d3",
"name": "productTitle",
"type": "string",
"value": "={{ $json.productTitle }}"
},
{
"id": "1dcbb87d-c334-42e6-947e-3ef53496031c",
"name": "price",
"type": "number",
"value": "={{ $json.price }}"
},
{
"id": "00c79031-b624-4ac4-a6dc-1415bbc99b96",
"name": "productRating",
"type": "number",
"value": "={{ $json.productRating }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "8303de9c-cd7b-4b0e-9872-3288adda8e3e",
"name": "保存FB数据",
"type": "n8n-nodes-base.set",
"position": [
-960,
32
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "36d7a682-5612-4303-9074-e9b4af4d70ab",
"name": "snapshot.page_name",
"type": "string",
"value": "={{ $json.snapshot.page_name }}"
},
{
"id": "33a6254a-1d92-4b7f-b93f-db437bacbfa9",
"name": "snapshot.page_profile_uri",
"type": "string",
"value": "={{ $json.snapshot.page_profile_uri }}"
},
{
"id": "f20599df-72d4-4aa9-bbff-752989bb8308",
"name": "snapshot.caption",
"type": "string",
"value": "={{ $json.snapshot.cards[0].link_url }}"
},
{
"id": "f4e5ed8c-3486-46b5-a52f-fd764f069dc5",
"name": "snapshot.cards[0].link_url",
"type": "string",
"value": "={{ $json.snapshot.cards[0].link_url }}"
},
{
"id": "9cc1a88d-3a08-433f-8952-0167d7c02648",
"name": "snapshot.body.text",
"type": "string",
"value": "={{ $json.snapshot.body.text }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "6c461b84-6113-4e85-a56b-0497cfe8ebfc",
"name": "在表格中追加行",
"type": "n8n-nodes-base.googleSheets",
"position": [
16,
-304
],
"parameters": {
"columns": {
"value": {
"Price": "={{ $json.price }}",
"Rating": "={{ $json.productRating }}",
"Link URL": "={{ $('SaveFBData').item.json.snapshot.cards[0].link_url }}",
"AmazonURL": "={{ $json.amazonURL }}",
"FB Page Name": "={{ $('SaveFBData').item.json.snapshot.page_name }}",
"ProductTitle": "={{ $('Product Name Finder').item.json.message.content }}"
},
"schema": [
{
"id": "FB Page Name",
"type": "string",
"display": true,
"required": false,
"displayName": "FB Page Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Link URL",
"type": "string",
"display": true,
"required": false,
"displayName": "Link URL",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "ProductTitle",
"type": "string",
"display": true,
"required": false,
"displayName": "ProductTitle",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "AmazonURL",
"type": "string",
"display": true,
"required": false,
"displayName": "AmazonURL",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Price",
"type": "string",
"display": true,
"required": false,
"displayName": "Price",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Rating",
"type": "string",
"display": true,
"required": false,
"displayName": "Rating",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "row_number",
"type": "number",
"display": true,
"removed": true,
"readOnly": true,
"required": false,
"displayName": "row_number",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"row_number"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1k5-Arb55v8HoIJueza4GrCiddTueK6thM6gqbWk8gaE/edit#gid=0",
"cachedResultName": "Tabellenblatt1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1k5-Arb55v8HoIJueza4GrCiddTueK6thM6gqbWk8gaE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1k5-Arb55v8HoIJueza4GrCiddTueK6thM6gqbWk8gaE/edit?usp=drivesdk",
"cachedResultName": "Upwork - Abdelmageed - 07/28 - v1.0 - AmazonSearchTest"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "wvNvKEMKTceQSxtR",
"name": "Google Sheets account"
}
},
"typeVersion": 4.6
},
{
"id": "cb85f819-e250-495c-9c22-3f95339f68ec",
"name": "获取亚马逊搜索结果",
"type": "n8n-nodes-base.httpRequest",
"onError": "continueRegularOutput",
"position": [
992,
128
],
"parameters": {
"options": {}
},
"typeVersion": 4.2,
"alwaysOutputData": true
},
{
"id": "9b0b5ec2-f984-45c9-989c-a990a160f3b6",
"name": "产品名称查找器",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
64,
112
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini",
"cachedResultName": "GPT-4.1-MINI"
},
"options": {},
"messages": {
"values": [
{
"role": "system",
"content": "=You are a helpful assistant. You take a Facebook ad's scraped website content, and search for a product being sold on that website. You only take one product, and find the product's name.\n\nThe purpose of this is to search that exact product on Amazon. Thus as an output, you formate that product's name as if you'd want to search it on Amazon. \n\n## Rules\n- If you don't get any content from the website, use the Facebook Ad page name, caption or body text to find the product name. If you still can't find it, say \"No Product Found\" as output.\n\n## Tools\n- Here's the website's scraped content: {{ $json.plainText }}\n- Facebook Ad Page Name: {{ $('SaveFBData').item.json.snapshot.page_name }}\n- Facebook Ad Caption: {{ $('SaveFBData').item.json.snapshot.caption }}\n- Facebook Ad Body Text: {{ $('SaveFBData').item.json.snapshot.body.text }}\n"
},
{}
]
}
},
"credentials": {
"openAiApi": {
"id": "V3Jm4IHcAE2t5qRT",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "e726b9e1-4c11-4a29-9bc6-4aa5b3aca3e9",
"name": "如果未找到产品",
"type": "n8n-nodes-base.if",
"position": [
416,
112
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "27e73c18-2a7e-47f1-9936-151785ce8633",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.message.content }}",
"rightValue": "No Product Found"
}
]
}
},
"typeVersion": 2.2
},
{
"id": "5540ad53-3dcd-40d5-b736-ba013b5b8ba7",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1680,
-128
],
"parameters": {
"color": 5,
"width": 864,
"height": 368,
"content": "## 📤 提取FB广告库"
},
"typeVersion": 1
},
{
"id": "68fc52a9-56a4-41ca-b89d-135ebf672ad8",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-448,
-16
],
"parameters": {
"color": 6,
"width": 1024,
"height": 304,
"content": "## 🔎 查找产品名称"
},
"typeVersion": 1
},
{
"id": "441bbbce-12bc-41f5-bb98-89906d2991be",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
688,
-16
],
"parameters": {
"color": 2,
"width": 928,
"height": 320,
"content": "## 🔎 在亚马逊上查找产品"
},
"typeVersion": 1
},
{
"id": "8e83394d-661a-4254-a422-ce916b1fd81e",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-448,
-416
],
"parameters": {
"color": 4,
"width": 704,
"height": 272,
"content": "## 📥 将产品插入表格"
},
"typeVersion": 1
},
{
"id": "1634ef7c-f911-468c-ad22-a07c6dba6309",
"name": "如果找到亚马逊URL",
"type": "n8n-nodes-base.if",
"position": [
-304,
-304
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "3e78fef9-a7e1-42d1-abdb-bd3215d535b4",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $json.amazonURL }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "ce0793de-223d-4eac-bf15-c7d7bcac1d03",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
1696,
-16
],
"parameters": {
"color": 7,
"width": 512,
"height": 304,
"content": "## 限制"
},
"typeVersion": 1
},
{
"id": "7f80d667-558a-4ea4-a3f3-f752f96a61fc",
"name": "便签5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2512,
-320
],
"parameters": {
"color": 7,
"width": 576,
"height": 608,
"content": "# 👋 介绍"
},
"typeVersion": 1
},
{
"id": "1a8029ba-aa0d-4d85-9dd7-de178ef54f30",
"name": "便签6",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2368,
64
],
"parameters": {
"color": 7,
"width": 288,
"height": 224,
"content": ""
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "76568f5a-ae86-45e9-8936-7fd9f8d5b43b",
"connections": {
"Limit": {
"main": [
[
{
"node": "SaveItems",
"type": "main",
"index": 0
}
]
]
},
"Filter": {
"main": [
[
{
"node": "Limit",
"type": "main",
"index": 0
}
]
]
},
"SaveItems": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"SaveFBData": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Edit Fields1": {
"main": [
[
{
"node": "Filter",
"type": "main",
"index": 0
}
]
]
},
"Manual Trigger": {
"main": [
[
{
"node": "Run FB Library Actor",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[
{
"node": "If Amazon URL Found",
"type": "main",
"index": 0
}
],
[
{
"node": "Scrape Website Content",
"type": "main",
"index": 0
}
]
]
},
"If Amazon URL Found": {
"main": [
[
{
"node": "Append row in sheet",
"type": "main",
"index": 0
}
]
]
},
"If No Product Found": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
],
[
{
"node": "Run Amazon Search Actor",
"type": "main",
"index": 0
}
]
]
},
"Product Name Finder": {
"main": [
[
{
"node": "If No Product Found",
"type": "main",
"index": 0
}
]
]
},
"Turn Into PlainText": {
"main": [
[
{
"node": "Product Name Finder",
"type": "main",
"index": 0
}
]
]
},
"Run FB Library Actor": {
"main": [
[
{
"node": "Get Actor's Scraped Content",
"type": "main",
"index": 0
}
]
]
},
"Scrape Website Content": {
"main": [
[
{
"node": "Turn Into PlainText",
"type": "main",
"index": 0
}
]
]
},
"Run Amazon Search Actor": {
"main": [
[
{
"node": "Get Amazon Search Results",
"type": "main",
"index": 0
}
]
]
},
"Get Amazon Search Results": {
"main": [
[
{
"node": "Edit Fields1",
"type": "main",
"index": 0
}
]
]
},
"Get Actor's Scraped Content": {
"main": [
[
{
"node": "SaveFBData",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 市场调研
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
自定义冷邮件破冰内容生成器
通过Apollo线索抓取和GPT-4.1自动化个性化冷邮件
Set
Code
Slack
+7
24 节点Richard Besier
潜在客户开发
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他
基于AI的潜在客户生成系统(邮件个性化和LinkedIn)
基于AI的潜在客户生成系统:包含邮件个性化和LinkedIn功能
If
Code
Limit
+11
51 节点Matthieu
潜在客户开发
潜在客户开发与邮件工作流
使用Google Maps、SendGrid和AI自动化B2B潜在客户开发与邮件营销
If
Set
Code
+21
141 节点Ezema Kingsley Chibuzo
潜在客户开发
我的工作流5
使用AI邮件个性化的自动化LinkedIn潜在客户生成(未完成)
If
Set
Code
+9
37 节点Matthieu
销售
使用LinkedIn、OpenAI和Sales Navigator创建合格线索和冷呼叫脚本
通过LinkedIn、OpenAI和Sales Navigator创建合格线索和冷呼叫脚本
If
Code
Limit
+11
47 节点Matthieu
潜在客户开发
工作流信息
难度等级
高级
节点数量24
分类1
节点类型11
作者
Richard Besier
@richardbHey 👋 I've worked with more or less every major no-code automation platform out there - now showing and building AI operating systems for businesses. If you need further help with one of my builds, or just want to chat, feel free to comment and I'll happily respond.
外部链接
在 n8n.io 查看 →
分享此工作流