Scrape the top 3 articles from Hacker News and email yourself a summary every weekday
Example tasks
Scrape the top 3 articles from Hacker News and email yourself a summary every weekday
This example demonstrates how to scrape the top 3 articles from Hacker News using BrowserBase and Puppeteer, summarize them with ChatGPT and send a nicely formatted email summary to yourself every weekday using Resend.
WEB SCRAPING: When web scraping, you MUST use a proxy to comply with our terms of service. Direct scraping of third-party websites without the site owner’s permission using Trigger.dev Cloud is prohibited and will result in account suspension. See this example which uses a proxy.
First up, add these build settings to your trigger.config.ts file:
trigger.config.ts
import{ defineConfig }from"@trigger.dev/sdk/v3";import{ puppeteer }from"@trigger.dev/build/extensions/puppeteer";exportdefaultdefineConfig({ project:"<project ref>",// Your other config settings... build:{// This is required to use the Puppeteer library extensions:[puppeteer()],},});
Learn more about the trigger.config.ts file including setting default retry settings, customizing the build environment, and more.
Set the following environment variable in your local .env file to run this task locally. And before deploying your task, set them in the Trigger.dev dashboard or using the SDK:
BROWSERBASE_API_KEY: "<your BrowserBase API key>"OPENAI_API_KEY: "<your OpenAI API key>"RESEND_API_KEY: "<your Resend API key>"
To prevent the main example from becoming too cluttered, we’ll create a separate file for our email template. It’s formatted using React Email components so you’ll need to install the package to use it.
Notice how this file is imported into the main task code and passed to Resend to send the email.
To test this example task locally, be sure to install any packages from the build extensions you added to your trigger.config.ts file to your local machine. In this case, you need to install .
To test this task in the dashboard, use the Test page and set the schedule date to “Now” to ensure the task triggers immediately. Then click “Run test” and wait for the task to complete.