🥳加入无抓取社区领取您的免费试用,访问我们强大的网页抓取工具包!
返回博客

如何在 Pipedream 上使用 Scrapeless 跟踪 Google 搜索结果?

Alex Johnson
Alex Johnson

Senior Web Scraping Engineer

03-Jul-2025

你已经知道——Scrapeless已成功在Pipedream上发布!这大大提升了Scrapeless在帮助构建AI代理和自动化工作流程方面的便利性。只需使用节点链接并输入简单代码,您就可以完成并反复执行自动化程序。在本出色的教程中,我们将尝试使用Scrapeless的抓取API模块来跟踪关键词更新结果:Revenged Love

我迫不及待想要开始这篇文章!

👉 了解节点用法的更多信息

关键前提条件

如何在Pipedream上使用Scrapeless?只需几个基本设置,您就可以将Scrapeless连接到Pipedream,自动收集和处理从任何搜索引擎抓取的数据。

获取Scrapeless API密钥

如果您还没有Scrapeless账户:

  • 注册一个Scrapeless账户
  • 在仪表板上创建您的Scrapeless API密钥。
获取Scrapeless API密钥

配置Pipedream

创建一个Pipedream账户并在Pipedream中设置您的Scrapeless API密钥。现在,转到Pipedream中的“账户”标签,并在那里添加密钥,如下所示:

在Pipedream上配置Scrapeless API密钥

然后,像这样设置您的API密钥:

设置您的API密钥

工作流程概述

一切都为您准备好了!以下是我们将使用的节点:

触发器抓取APINodejs(转换输出结构) → OpenAI ChatNodejs(在Discord上跟踪关键词)

第一步。设置触发器

跟踪数据的关键是重复执行。我们可以在工作流程的开始使用一个触发器来设置执行间隔。点击“添加触发器”并配置一个“自定义间隔”。现在,您可以根据需要设置计划。

设置触发器

第二步。配置抓取API模块

我们将使用抓取API模块中的Google搜索功能调用Deep SerpApi进行关键词搜索:revenged love。以下是我使用的参数:

  • 查询revenged love
  • 语言en
  • 国家us
配置抓取API模块

点击“测试”,以成功返回实时搜索结果。为了等待异步任务的结果,您可能需要在提交查询后手动点击继续

提交查询

第三步。添加Node.js 20.x节点

由于Google搜索以HTML格式返回结果,这在大多数情况下并不实用,我们可以添加一个数据转换节点来清理和过滤出我们需要的内容,例如:

  • video_results
  • inline_images
添加Node.js 20.x节点

需要用到的筛选代码为:

Copy
// import axios from "axios"

export default defineComponent({
  async run({ steps, $ }) {
    // 使用步骤对象引用上一个步骤的数据并返回数据,以便在未来的步骤中使用
    const videos = steps.get_data.$return_value?.video_results || {}
    const result = steps.get_data.$return_value?.inline_images || {}
    return JSON.stringify({
      ...videos,
      ...result
    })
  },
})

以下是我们获取到的返回结果:

Copy
{"0":{"position":1,"thumbnail":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSd0eIXSUrXjBwCh3aU30jL3aVig5lxDtQL9w&s","related_content_id":"CnMxDy61BewRJM,8yBwVXcZCBr9dM","related_content_link":"https://www.google.com/search/about-this-image?img=H4sIAAAAAAAA_-MS5fh88MDqr-vaWqQEup4d_flg6dumN4wAqmApcRcAAAA%3D&q=https://www.viki.com/tv/38371c-first-love-again&ctx=iv&hl=en-US","source":"www.viki.com","source_logo":"","title":"First love, Again | Watch with English Subtitles & More | Viki","link":"https://www.viki.com/tv/38371c-first-love-again","original":"https://1.vikiplatform.com/c/38371c/25a36c57fc.jpg?x=b&a=0x0","original_width":3120,"original_height":1744,"in_stock":false,"is_product":false},"1":{"position":2,"title":"ENG SUB Revenged Love|EP01:Falling for the rival","link":"https://www.youtube.com/watch?v=tlCSMHgOKbE","snippet":"ENG SUB Revenged Love|EP01:Falling for the rival. 1.9M views · 2 weeks ago #RevengedLove #BL ...more. RevengedLove. 307K.","duration":"47:42","rich_snippet":{"top":{"detected_extensions":{},"extensions":[]}},"video_link":"https://encrypted-vtbn0.gstatic.com/video?q=tbn:ANd9GcR2yueHQqTvdFyBeda4_-uoEOQInAJfRm9F9A"},"2":{"position":3,"title":"EP.5 Revenged Love (2025) Engsub - video Dailymotion","link":"https://www.dailymotion.com/video/x9lrrn8","snippet":"Watch EP.5 Revenged Love (2025) Engsub - RJSN on Dailymotion. ... Revenged Love (2025) Ep 6 Eng Sub #RevengedLove · Daily Drama HD™. yesterday.","duration":"44:22","rich_snippet":{"top":{"detected_extensions":{},"extensions":[]}},"video_link":"https://encrypted-vtbn0.gstatic.com/video?q=tbn:ANd9GcS6XBgsSk3vqCefja0bVhQSxavTw43aP5dqJg"},"3":{"position":4,"title":"(2025) REVENGED LOVE EP 8 ENG SUB - video Dailymotion","link":"https://www.dailymotion.com/video/x9m5r3a","snippet":"EP.8 Revenged Love (2025) Engsub · RJSN. yesterday. 1:01:39. Revenged Love (2025) EP 8 ENG SUB · Spirit Studios HD. yesterday. 1:06:11. (2025) ...","duration":"41:17","rich_snippet":{"top":{"detected_extensions":{},"extensions":[]}}}}

Step 4. 添加 OpenAI Chat 节点

为了方便直接并且简单地获取我们最需要的数据。建议你可以添加 OpenAI 的Chat 节点进行高效的数据整合。我们需要绑定 OpenAI API key 并选择目标模型.

如果你需要的返回数据很多,请一定不要忘记添加 integer - Max Tokens。以免返回失败或超时。

添加 OpenAI Chat 节点

Discord 对于数据的格式有较为严格的要求,同时也为了数据追踪的美观度,现在我们需要给 Chat 明确的指令:只返回目标参数的 JSON 格式内容,不需要以 Markdown 类型返回结果。这样便于我们之后配置程序。

可以参考我的 Prompt 进行完善:

Copy
Format the following JSON search results into an array of objects for Discord embeds. Each object must include:

- title (string)
- link (string)
- description (string)
- image_url (string)
- source (string)
- duration (string, optional)

❗️Output only raw JSON without any markdown code block, backticks, or explanation. If it is a arrary javascript type, you need output the Array type not a string type

Data:
{{steps.transform_data.$return_value}} //返回结果的地址

steps.transform_data.$return_value 是你工作流上一步返回的数组。

Test 之后获取返回结果,但是请忽略其他不重要的内容,我们重点关注 generated_message 下面的 content的内容即可:

OpenAI generated_message
Copy
[{"title":"First love, Again | Watch with English Subtitles & More | Viki","link":"https://www.viki.com/tv/38371c-first-love-again","description":"First love, Again | Watch with English Subtitles & More | Viki","image_url":"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSd0eIXSUrXjBwCh3aU30jL3aVig5lxDtQL9w&s","source":"www.viki.com"},{"title":"ENG SUB Revenged Love|EP01:Falling for the rival","link":"https://www.youtube.com/watch?v=tlCSMHgOKbE","description":"ENG SUB Revenged Love|EP01:Falling for the rival. 1.9M views · 2 weeks ago #RevengedLove #BL ...more. RevengedLove. 307K.","image_url":"https://encrypted-vtbn0.gstatic.com/video?q=tbn:ANd9GcR2yueHQqTvdFyBeda4_-uoEOQInAJfRm9F9A","source":"www.youtube.com","duration":"47:42"},{"title":"EP.5 Revenged Love (2025) Engsub - video Dailymotion","link":"https://www.dailymotion.com/video/x9lrrn8","description":"Watch EP.5 Revenged Love (2025) Engsub - RJSN on Dailymotion. ... Revenged Love (2025) Ep 6 Eng Sub #RevengedLove · Daily Drama HD™. yesterday.","image_url":"https://encrypted-vtbn0.gstatic.com/video?q=tbn:ANd9GcS6XBgsSk3vqCefja0bVhQSxavTw43aP5dqJg","source":"www.dailymotion.com","duration":"44:22"},{"title":"(2025) REVENGED LOVE EP 8 ENG SUB - video Dailymotion","link":"https://www.dailymotion.com/video/x9m5r3a","description":"EP.8 Revenged Love (2025) Engsub · RJSN. yesterday. 1:01:39. Revenged Love (2025) EP 8 ENG SUB · Spirit Studios HD. yesterday. 1:06:11. (2025) ...","image_url":"https://encrypted-vtbn0.gstatic.com/video?q=tbn:ANd9GcS6XBgsSk3vqCefja0bVhQSxavTw43aP5dqJg","source":"www.dailymotion.com","duration":"41:17"}]

Step 5. Track the Keywords Updates on Discord

恭喜!所有数据都已经准备好了!我们现在只需要完成最后一步:绑定 Discord 并且配置自动转发程序。由于 Chat提供的结果为 JSON格式,我们可以添加参数进行格式转化:'string' ? JSON.parse(_res) : _res.

Copy
import { axios } from "@pipedream/platform";

export default defineComponent({
  async run({ steps, $ }) {
    
    const _res = steps.chat1.$return_value.generated_message.content;
    const results = typeof _res === 'string' ? JSON.parse(_res) : _res

    const discordWebhookUrl = "YOUR_DISCORD_WEBHOOK";

  
    const embeds = results.map(item => ({
      title: item.title,
      url: item.link,
      description: item.description || "No description.",
      color: 0x7289DA, // Discord blurple
      image: item.image_url ? { url: item.image_url } : undefined,
      fields: [
        item.source ? { name: "Source", value: item.source, inline: true } : undefined,
        item.duration ? { name: "Duration", value: item.duration, inline: true } : undefined,
      ].filter(Boolean),
      timestamp: new Date().toISOString(),
    }));

    
    const payload = {
      content: "🔎 **Search Results:**",
      embeds: embeds.slice(0, 10),
    };

    try {
      const response = await axios($, {
        method: "POST",
        url: discordWebhookUrl,
        headers: {
          "Content-Type": "application/json",
        },
        data: payload,
      });

      console.log("Sent to Discord:", response.status);
      return { success: true, count: embeds.length };
    } catch (error) {
      console.error("Error sending to Discord:", error.message);
      return { success: false, error: error.message };
    }
  },
});
  • steps.Code_step.$return_value 是你工作流上一步返回的数组JSON。
  • 每条数据生成一个Discord embed,包括标题、链接、描述、图片、来源和时间戳。
  • 一次发送最多10条embed(Discord限制),如果你有更多数据可以改成分批发送。
  • 你可以修改content字段里的文本,变成你想展示的标题或描述。

步骤 6:检查 Discord 结果

点击“测试”,执行完成后,我们就可以切换到 Discord 查看结果了!

检查 Discord 结果

结语

在本教程中,我们成功演示了如何将 Scrapeless 与 Pipedream 集成,构建一个完整的工作流程,用于自动跟踪关键词“Revenged Love”的搜索结果。您学习了如何:

  • 配置 API
  • 解析 HTML
  • 使用 OpenAI Chat 组织数据
  • 向 Discord 发送实时更新

无论您是监控品牌趋势、热门节目、市场动态,还是为 AI 代理构建数据输入渠道,Scrapeless + Pipedream 都是不可或缺的工具组合。

👉 立即在 Pipedream 上试用 Scrapeless!

在Scrapeless,我们仅访问公开可用的数据,并严格遵循适用的法律、法规和网站隐私政策。本博客中的内容仅供演示之用,不涉及任何非法或侵权活动。我们对使用本博客或第三方链接中的信息不做任何保证,并免除所有责任。在进行任何抓取活动之前,请咨询您的法律顾问,并审查目标网站的服务条款或获取必要的许可。

最受欢迎的文章

目录