8
n8n 中文网amn8n.com

使用PDF.co从PDF文档提取链接和URL

中级

这是一个Document Extraction领域的自动化工作流,包含 10 个节点。主要使用 Code, PDFco Api, FormTrigger, HttpRequest 等节点。 使用PDF.co从PDF文档提取链接和URL

前置要求
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "8396a2c42d7edc37401c19b3909f25edcb0e4a6dc3914c824fddd73a329a575c",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "f6e71b74-1ecb-43e8-baa2-bf05536d01b7",
      "name": "加载 PDF",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -2224,
        -384
      ],
      "webhookId": "a919be0e-e4c8-4b9c-b8e9-b1ffdd6ef9fb",
      "parameters": {
        "options": {},
        "formTitle": "pdf",
        "formFields": {
          "values": [
            {
              "fieldType": "file",
              "fieldLabel": "data",
              "multipleFiles": false,
              "acceptFileTypes": ".pdf"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "f24dd98b-b3c4-47f1-8345-10097e53803d",
      "name": "上传",
      "type": "n8n-nodes-pdfco.PDFco Api",
      "position": [
        -2016,
        -384
      ],
      "parameters": {
        "name": "test",
        "operation": "Upload File to PDF.co",
        "binaryData": true
      },
      "credentials": {
        "pdfcoApi": {
          "id": "RgIt0qlGxtcDwXW7",
          "name": "PDF.co account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b354cde6-5354-4052-9a6c-d66c328a946f",
      "name": "PDF 转 HTML",
      "type": "n8n-nodes-pdfco.PDFco Api",
      "position": [
        -1776,
        -384
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "operation": "Convert from PDF",
        "advancedOptions": {}
      },
      "credentials": {
        "pdfcoApi": {
          "id": "RgIt0qlGxtcDwXW7",
          "name": "PDF.co account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e15b5c0d-5a46-4faa-828f-25e56cfce322",
      "name": "获取 HTML",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1568,
        -384
      ],
      "parameters": {
        "url": "={{ $json.url }}",
        "options": {}
      },
      "typeVersion": 4.2
    },
    {
      "id": "73506c94-6265-4d89-b386-e908285d14e0",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2288,
        -448
      ],
      "parameters": {
        "width": 208,
        "height": 240,
        "content": "## 加载 PDF"
      },
      "typeVersion": 1
    },
    {
      "id": "6d23ab8a-5bae-4317-b73e-fb1b2ba8ff16",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2080,
        -448
      ],
      "parameters": {
        "color": 2,
        "height": 240,
        "content": "## 上传到 PDF.CO"
      },
      "typeVersion": 1
    },
    {
      "id": "72be2279-3028-4c24-8973-00879cff375a",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1840,
        -448
      ],
      "parameters": {
        "color": 4,
        "width": 224,
        "height": 240,
        "content": "## PDF 转 HTML"
      },
      "typeVersion": 1
    },
    {
      "id": "cebf4aeb-549c-4c9e-84eb-41d880834fb5",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1616,
        -448
      ],
      "parameters": {
        "width": 192,
        "height": 240,
        "content": "## 获取 HTML"
      },
      "typeVersion": 1
    },
    {
      "id": "8f6d9763-dece-45f6-a78b-1b5f6891f2fa",
      "name": "代码1",
      "type": "n8n-nodes-base.code",
      "position": [
        -1360,
        -384
      ],
      "parameters": {
        "jsCode": "// Recorrer todos los items que entran al nodo\nconst resultados = [];\n\nfor (const item of $input.all()) {\n  const texto = item.json.data || '';\n  // Regex para URLs (http, https, www)\n  const regexUrl = /(https?:\\/\\/[^\\s]+)|(www\\.[^\\s]+)/gi;\n  \n  // Extraer URLs, si no hay ninguna, el resultado es []\n  const urls = texto.match(regexUrl) || [];\n  \n  // Por cada URL encontrada, crear un nuevo item con la URL\n  for (const url of urls) {\n    resultados.push({ json: { url } });\n  }\n}\n\n// Devolver un array de objetos con las URLs extraídas\nreturn resultados;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "0c49f98f-0b3c-4c47-ad34-b60b02c5f3a5",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1424,
        -448
      ],
      "parameters": {
        "color": 5,
        "width": 208,
        "height": 240,
        "content": "## 获取 URL"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Upload": {
      "main": [
        [
          {
            "node": "PDF to HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get HTML": {
      "main": [
        [
          {
            "node": "Code1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load PDF": {
      "main": [
        [
          {
            "node": "Upload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PDF to HTML": {
      "main": [
        [
          {
            "node": "Get HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 文档提取

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量10
分类1
节点类型5
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
Mauricio Perera

Mauricio Perera

@rckflr

Automation consultant with over 10 years of experience specializing in AI, no-code, and workflow optimization. I’ve delivered tailored AI and NLP solutions across real estate, healthcare, and more, enhancing efficiency and customer experiences. Proficient in tools like Make, Airtable, and Zapier, I also integrate GPT models to create scalable, innovative automations. Contact me to discuss custom n8n workflows or advanced automations to streamline your processes.

外部链接
在 n8n.io 查看

分享此工作流