{ "name": "定时抓取X相关博主最新推文", "nodes": [ { "parameters": {}, "type": "n8n-nodes-base.noOp", "typeVersion": 1, "position": [ -500, -100 ], "id": "d2a96a45-21f8-464a-922c-49d144facfc9", "name": "No Operation, do nothing" }, { "parameters": { "maxItems": 2 }, "type": "n8n-nodes-base.limit", "typeVersion": 1, "position": [ -1380, 220 ], "id": "068aecde-e39a-4ebb-ac7d-4324d233e401", "name": "Limit" }, { "parameters": { "assignments": { "assignments": [ { "id": "2e5fc709-730b-45f6-906e-9e221c008fb6", "name": "users", "value": "=[\"imxiaohu\",\"hq4ai\",\"Yangyixxxx\"]", "type": "array" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ -2560, -20 ], "id": "d9704b1d-adc6-4022-95b7-b054321e87e7", "name": "设置多个博主或者官媒" }, { "parameters": { "fieldToSplitOut": "users", "options": {} }, "type": "n8n-nodes-base.splitOut", "typeVersion": 1, "position": [ -2360, -20 ], "id": "c0d53b2b-0c54-4d9d-9c6b-1a4fce104f90", "name": "分成多条" }, { "parameters": { "options": {} }, "type": "n8n-nodes-base.splitInBatches", "typeVersion": 3, "position": [ -2040, -80 ], "id": "f438b3ae-4cc7-4b30-832b-0ee663d7f6e1", "name": "批量执行(每次一条)" }, { "parameters": { "assignments": { "assignments": [ { "id": "5edc7e67-200c-4da6-b9c0-666b519c1f66", "name": "count", "value": 1, "type": "number" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ -1740, -20 ], "id": "a5132ef5-bc99-44c5-8c40-94e6e2e521f2", "name": "设置计数" }, { "parameters": { "assignments": { "assignments": [ { "id": "74c16187-0268-4451-ae1b-a4cb5d3fa50f", "name": "counter", "value": "={{ $json.count }}", "type": "number" }, { "id": "ee7d6273-e36a-4351-a812-7ec2ce1df288", "name": "cursor", "value": "={{ $json.cursor }}", "type": "string" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ -1500, -40 ], "id": "ffebc7f0-f084-460e-96b5-a5972d88592f", "name": "计数和游标" }, { "parameters": { "url": "https://api.twitterapi.io/twitter/user/last_tweets", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "sendQuery": true, "queryParameters": { "parameters": [ { "name": "userName", "value": "={{ $('分成多条').item.json.users }}" }, { "name": "cursor", "value": "={{ $json.cursor }}" } ] }, "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "position": [ -1300, -20 ], "id": "12de9909-7c10-4684-91d2-5a4ea688b882", "name": "抓取博主最新推文", "credentials": { "httpHeaderAuth": { "id": "OcfR1UpEUh4FnByb", "name": "X-API-Key" } } }, { "parameters": { "fieldToSplitOut": "data.tweets", "options": {} }, "type": "n8n-nodes-base.splitOut", "typeVersion": 1, "position": [ -1100, -40 ], "id": "dc9cd547-4dac-40f5-9e1a-5ad4d3df4ac1", "name": "分成多条推文" }, { "parameters": { "operation": "appendOrUpdate", "documentId": { "__rl": true, "value": "1GI0WH4Qr4VbTkpNeoq7OhMipW3w6avCsUCtOmQ0uvX0", "mode": "list", "cachedResultName": "X博主最新推文", "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1GI0WH4Qr4VbTkpNeoq7OhMipW3w6avCsUCtOmQ0uvX0/edit?usp=drivesdk" }, "sheetName": { "__rl": true, "value": "gid=0", "mode": "list", "cachedResultName": "工作表1", "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1X9U9P_cOFG56Aj4doU6lTP68c9tXTId1Iee_BZ8E844/edit#gid=0" }, "columns": { "mappingMode": "defineBelow", "value": { "type": "={{ $json.type }}", "id": "={{ $json.id }}", "url": "={{ $json.url }}", "twitterUrl": "={{ $json.twitterUrl }}", "text": "={{ $json.text }}", "source": "={{ $json.source }}", "retweetCount": "={{ $json.retweetCount }}", "replyCount": "={{ $json.replyCount }}", "likeCount": "={{ $json.likeCount }}", "quoteCount": "={{ $json.quoteCount }}" }, "matchingColumns": [ "id" ], "schema": [ { "id": "type", "displayName": "type", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": false }, { "id": "id", "displayName": "id", "required": false, "defaultMatch": true, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": false }, { "id": "url", "displayName": "url", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": false }, { "id": "twitterUrl", "displayName": "twitterUrl", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": false }, { "id": "text", "displayName": "text", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": false }, { "id": "source", "displayName": "source", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": false }, { "id": "retweetCount", "displayName": "retweetCount", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": false }, { "id": "replyCount", "displayName": "replyCount", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": false }, { "id": "likeCount", "displayName": "likeCount", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": false }, { "id": "quoteCount", "displayName": "quoteCount", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": false }, { "id": "viewCount", "displayName": "viewCount", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "createdAt", "displayName": "createdAt", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "lang", "displayName": "lang", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "bookmarkCount", "displayName": "bookmarkCount", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "isReply", "displayName": "isReply", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "inReplyToId", "displayName": "inReplyToId", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "conversationId", "displayName": "conversationId", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "inReplyToUserId", "displayName": "inReplyToUserId", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "inReplyToUsername", "displayName": "inReplyToUsername", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "author", "displayName": "author", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "extendedEntities", "displayName": "extendedEntities", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "card", "displayName": "card", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "place", "displayName": "place", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "entities", "displayName": "entities", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "quoted_tweet", "displayName": "quoted_tweet", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true }, { "id": "retweeted_tweet", "displayName": "retweeted_tweet", "required": false, "defaultMatch": false, "display": true, "type": "string", "canBeUsedToMatch": true, "removed": true } ], "attemptToConvertTypes": false, "convertFieldsToString": false }, "options": {} }, "type": "n8n-nodes-base.googleSheets", "typeVersion": 4.5, "position": [ -880, -40 ], "id": "7bd93b00-f345-479a-8b8c-b3f151cffbee", "name": "每条推文相关信息插入表格", "credentials": { "googleSheetsOAuth2Api": { "id": "r8uKSALoPUxO2eyG", "name": "Google Sheets account" } } }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 2 }, "conditions": [ { "id": "2651980b-5328-479a-b46b-526e93a66fb3", "leftValue": "={{ $('计数和游标').item.json.counter }}", "rightValue": 1, "operator": { "type": "number", "operation": "equals" } } ], "combinator": "and" }, "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.2, "position": [ -680, -40 ], "id": "af6fd982-f3b4-4cd4-9f25-8098a985e73d", "name": "控制请求次数" }, { "parameters": { "jsCode": "const items = $input.all();\nreturn items.map(item =>{\n let newCount = 1;\n if(item.json && item.json.counter !==undefined){\n newCount = item.json.counter + 1;\n }\n if(!item.json){\n item.json = {}\n }\n item.json.count = newCount;\n return item;\n});" }, "type": "n8n-nodes-base.code", "typeVersion": 2, "position": [ -980, 220 ], "id": "b23b5a0f-b108-430b-b315-74767ad36b30", "name": "请求次数+1" }, { "parameters": { "assignments": { "assignments": [ { "id": "8e97911e-42c4-4d2a-b293-269c0eefff92", "name": "counter", "value": "={{ $('计数和游标').item.json.counter }}", "type": "number" }, { "id": "c5223618-5160-4ebf-8e49-f9d114668eed", "name": "cursor", "value": "={{ $('抓取博主最新推文').item.json.next_cursor }}", "type": "string" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ -1180, 220 ], "id": "71c58856-f47f-4221-830c-8cca577d8f70", "name": "获取下一次光标位置" }, { "parameters": { "assignments": { "assignments": [ { "id": "256950a5-7b7e-4d20-b362-2415de0363c6", "name": "count", "value": "={{ $json.count }}", "type": "number" }, { "id": "351951fe-a5ad-4462-b8bf-7bc0b985df7d", "name": "cursor", "value": "={{ $('获取下一次光标位置').item.json.cursor }}", "type": "string" } ] }, "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ -760, 220 ], "id": "4becf230-1848-4b90-ab05-bf64f2a183aa", "name": "设置+1后的count,和光标" }, { "parameters": { "rule": { "interval": [ { "field": "minutes", "minutesInterval": 30 } ] } }, "type": "n8n-nodes-base.scheduleTrigger", "typeVersion": 1.2, "position": [ -2780, -20 ], "id": "e8c8f84f-aef2-4169-8c21-8a6530ea49f3", "name": "定时触发" } ], "pinData": {}, "connections": { "No Operation, do nothing": { "main": [ [ { "node": "批量执行(每次一条)", "type": "main", "index": 0 } ] ] }, "Limit": { "main": [ [ { "node": "获取下一次光标位置", "type": "main", "index": 0 } ] ] }, "设置多个博主或者官媒": { "main": [ [ { "node": "分成多条", "type": "main", "index": 0 } ] ] }, "分成多条": { "main": [ [ { "node": "批量执行(每次一条)", "type": "main", "index": 0 } ] ] }, "批量执行(每次一条)": { "main": [ [], [ { "node": "设置计数", "type": "main", "index": 0 } ] ] }, "设置计数": { "main": [ [ { "node": "计数和游标", "type": "main", "index": 0 } ] ] }, "计数和游标": { "main": [ [ { "node": "抓取博主最新推文", "type": "main", "index": 0 } ] ] }, "抓取博主最新推文": { "main": [ [ { "node": "分成多条推文", "type": "main", "index": 0 } ] ] }, "分成多条推文": { "main": [ [ { "node": "每条推文相关信息插入表格", "type": "main", "index": 0 } ] ] }, "每条推文相关信息插入表格": { "main": [ [ { "node": "控制请求次数", "type": "main", "index": 0 } ] ] }, "控制请求次数": { "main": [ [ { "node": "No Operation, do nothing", "type": "main", "index": 0 } ], [ { "node": "Limit", "type": "main", "index": 0 } ] ] }, "请求次数+1": { "main": [ [ { "node": "设置+1后的count,和光标", "type": "main", "index": 0 } ] ] }, "获取下一次光标位置": { "main": [ [ { "node": "请求次数+1", "type": "main", "index": 0 } ] ] }, "设置+1后的count,和光标": { "main": [ [ { "node": "计数和游标", "type": "main", "index": 0 } ] ] }, "定时触发": { "main": [ [ { "node": "设置多个博主或者官媒", "type": "main", "index": 0 } ] ] } }, "active": false, "settings": { "executionOrder": "v1" }, "versionId": "c80bea4b-0af3-4f3a-954a-49768bd68b53", "meta": { "templateCredsSetupCompleted": true, "instanceId": "631787de6baf65b8f9272d61f0aa9fc0f846039de40a1cbde7808fe9a4326e3f" }, "id": "3aUP15vOKPM5THZo", "tags": [] }