Automated website monitoring with Anchor Browser
Automated web monitoring using Trigger.dev's task scheduling and Anchor Browser's AI-powered browser automation.
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.
Overview
This example demonstrates automated web monitoring using Trigger.dev's task scheduling and Anchor Browser's AI-powered browser automation tools.
The task runs daily at 5pm ET to find the cheapest Broadway tickets available for same-day shows.
How it works:
- Trigger.dev schedules and executes the monitoring task
- Anchor Browser spins up a remote browser session with an AI agent
- The AI agent uses computer vision and natural language processing to analyze the TDF website
- AI agent returns the lowest-priced show with specific details: name, price, and showtime
Tech stack
- Node.js runtime environment (version 18.2 or higher)
- Trigger.dev for task scheduling and task orchestration
- Anchor Browser for AI-powered browser automation
- Playwright for browser automation libraries (handled via external dependencies)
GitHub repo
View the Anchor Browser web scraper repo
Click here to view the full code for this project in our examples repository on GitHub. You can fork it and use it as a starting point for your own project.
Deploy this example to your project
Copies anchor-browser-web-scraper from GitHub, installs it, and deploys its tasks to your project’s production environment.
npx degit triggerdotdev/examples/anchor-browser-web-scraper anchor-browser-web-scraper
cd anchor-browser-web-scraper
npm install
npx trigger.dev@latest login
npx trigger.dev@latest deploy --project-ref <your-project-ref>If the example has a .env.example, set those variables in your project’s environment variables before deploying. To run the tasks on your machine instead, use dev in place of deploy.
Relevant code
Broadway ticket monitor task
This task runs daily at 5pm ET, in src/trigger/broadway-monitor.ts:
import { schedules } from "@trigger.dev/sdk";
import from "anchorbrowser";
export const broadwayMonitor = schedules.task({
: "broadway-ticket-monitor",
: "0 21 * * *",
: async (payload, { }) => {
const client = new ({
apiKey: process..ANCHOR_BROWSER_API_KEY!,
});
let session;
try {
// Create explicit session to get live view URL
session = await client.sessions.create();
.(`Session ID: ${session.data.id}`);
.(`Live View URL: https://live.anchorbrowser.io?sessionId=${session.data.id}`);
const response = await client.tools.performWebTask({
sessionId: session.data.id,
url: "https://www.tdf.org/discount-ticket-programs/tkts-by-tdf/tkts-live/",
prompt: `Look for the "Broadway Shows" section on this page. Find the show with the absolute lowest starting price available right now and return the show name, current lowest price, and show time. Be very specific about the current price you see. Format as: Show: [name], Price: [exact current price], Time: [time]`,
});
.("Raw response:", response);
const result = response.data.result?.result || response.data.result || response.data;
if (result && typeof result === "string" && result.("Show:")) {
.(`🎭 Best Broadway Deal Found!`);
.(result);
return {
success: true,
bestDeal: result,
liveViewUrl: `https://live.anchorbrowser.io?sessionId=${session.data.id}`,
};
} else {
.("No Broadway deals found today");
return { success: true, message: "No deals found" };
}
} finally {
if (session?.data?.id) {
try {
await client.sessions.delete(session.data.id);
} catch (cleanupError) {
.("Failed to cleanup session:", cleanupError);
}
}
}
},
});Build configuration
Since Anchor Browser uses browser automation libraries (Playwright) under the hood, we need to configure Trigger.dev to handle these dependencies properly by excluding them from the build bundle in trigger.config.ts:
import { } from "@trigger.dev/sdk";
export default ({
: "proj_your_project_id_here", // Get from Trigger.dev dashboard
: 3600, // 1 hour - plenty of time for web automation
: ["./src/trigger"],
build: {
: ["playwright-core", "playwright", "chromium-bidi"],
},
});Learn more
- View the Anchor Browser docs to learn more about Anchor Browser's AI-powered browser automation tools.
- Check out the source code for the Anchor Browser web scraper repo on GitHub.
- Browser our example projects to see how you can use Trigger.dev with other services.
Was this page helpful?
Last updated
Edit on GitHub