{
  "id": "Gen73",
  "name": "\u76e3\u6e2c Mobile01 \u8a0e\u8ad6\uff08PTT \u7248\uff09",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "cronExpression",
              "expression": "0 9 * * *"
            }
          ]
        }
      },
      "id": "n-sched",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        240,
        460
      ]
    },
    {
      "parameters": {
        "jsCode": "const board='Tech_Job';const keyword='AI';\nconst url='https://www.ptt.cc/bbs/'+board+'/search?q='+encodeURIComponent(keyword);\nreturn [{json:{board,keyword,url}}];"
      },
      "id": "n-input",
      "name": "Input (edit me)",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        460
      ]
    },
    {
      "parameters": {
        "options": {},
        "method": "GET",
        "url": "={{ $json.url }}",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Cookie",
              "value": "over18=1"
            },
            {
              "name": "User-Agent",
              "value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"
            }
          ]
        }
      },
      "id": "n-fetch",
      "name": "Fetch PTT",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        680,
        460
      ]
    },
    {
      "parameters": {
        "jsCode": "const j=$input.first().json;const html=j.data||j.body||'';\nconst re=/<div class=\\x22title\\x22>\\s*<a href=\\x22([^\\x22]+)\\x22>([^<]+)<\\/a>/g;\nconst items=[];let m;while((m=re.exec(html))!==null){const t=m[2].replace(/&amp;/g,'&').trim();items.push(t);if(items.length>=20)break;}\nconst meta=$('Input (edit me)').first().json;\nconst list=items.map((n,i)=>(i+1)+'. '+n).join('\\n');\nconst prompt='\u4f60\u662f\u8f3f\u60c5\u5206\u6790\u5e2b\u3002\u628a\u4ee5\u4e0b\u8ad6\u58c7\u8a0e\u8ad6\u6a19\u984c\u6574\u7406\u6210\u8f3f\u60c5\u5831\u544a\uff1a1)\u91cd\u9ede 2)\u98a8\u5411\u60c5\u7dd2 3)\u6ce8\u610f\u9ede\uff08\u770b\u677f '+meta.board+'\u3001\u95dc\u9375\u5b57 '+meta.keyword+'\uff09\\n\\n'+(list||'\uff08\u6c92\u6293\u5230\u6a19\u984c\uff0c\u8abf\u6574\u770b\u677f\u6216\u95dc\u9375\u5b57\uff09');\nreturn [{json:{count:items.length,prompt}}];"
      },
      "id": "n-parse",
      "name": "Parse PTT",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        900,
        460
      ]
    },
    {
      "parameters": {
        "options": {
          "timeout": 180000
        },
        "method": "POST",
        "url": "http://host.docker.internal:11434/api/chat",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ model: 'qwen2.5:latest', messages: [ { role: 'system', content: '\u4f60\u662f\u53f0\u7063\u4eba\uff0c\u4e00\u5f8b\u4f7f\u7528\u53f0\u7063\u7e41\u9ad4\u4e2d\u6587\u8207\u53f0\u7063\u6163\u7528\u8a9e\u56de\u8986\uff0c\u7d55\u5c0d\u4e0d\u8981\u51fa\u73fe\u4efb\u4f55\u7c21\u9ad4\u5b57\u6216\u4e2d\u570b\u7528\u8a9e\u3002' }, { role: 'user', content: $json.prompt } ], stream: false }) }}"
      },
      "id": "n-ollama",
      "name": "Summarize with Ollama",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1120,
        460
      ]
    },
    {
      "parameters": {
        "jsCode": "const data = $input.first().json;\nlet v = '';\ntry { v = (data.message && data.message.content) || (data.content && data.content[0] && data.content[0].text) || data.response || ''; } catch (e) {}\nif (!v) v = JSON.stringify(data);\nreturn [{ json: { summary: v } }];"
      },
      "id": "n-extract",
      "name": "Extract Result",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1340,
        460
      ]
    },
    {
      "parameters": {
        "options": {},
        "method": "POST",
        "url": "https://discord.com/api/webhooks/REPLACE_WITH_YOUR_WEBHOOK_URL",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ content: ('\ud83d\udde3\ufe0f \u76e3\u6e2c Mobile01 \u8a0e\u8ad6\uff08PTT \u7248\uff09\\n\\n' + ($json.summary || '')).slice(0, 1900) }) }}"
      },
      "id": "n-discord",
      "name": "Send to Discord",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1560,
        460
      ]
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Input (edit me)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Input (edit me)": {
      "main": [
        [
          {
            "node": "Fetch PTT",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch PTT": {
      "main": [
        [
          {
            "node": "Parse PTT",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse PTT": {
      "main": [
        [
          {
            "node": "Summarize with Ollama",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Summarize with Ollama": {
      "main": [
        [
          {
            "node": "Extract Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Result": {
      "main": [
        [
          {
            "node": "Send to Discord",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "tags": []
}