Skip to content

Stagehand agent to extract screenshots of Linkedin banner images#62

Open
aq17 wants to merge 6 commits intodevfrom
aq17/agent-screenshot
Open

Stagehand agent to extract screenshots of Linkedin banner images#62
aq17 wants to merge 6 commits intodevfrom
aq17/agent-screenshot

Conversation

@aq17
Copy link
Contributor

@aq17 aq17 commented Feb 20, 2026

Somewhat niche, somewhat interesting use case built for another customer demo.

Imagining this as an example of how to leverage Stagehand to download random media assets on websites where a user would typically "right-click and press save image" (OS-level commands) that Stagehand can't mimic with acts, but can instead extract the image links, navigate to the link, and ultimately take a screenshot of it instead


Note

Low Risk
Adds a self-contained example script and docs without modifying shared libraries or production logic; main risk is external flakiness from LinkedIn/Google automation and required credentials.

Overview
Adds a new typescript/agent-screenshot example that takes a company name, uses a Stagehand CUA agent to find the company’s LinkedIn page via Google, then uses stagehand.extract to grab the banner image URL and saves a clipped screenshot of the image to images/.

Includes an .env.example and a README with setup, required Browserbase/LLM credentials, and usage notes (stealth/proxy requirements and common failure modes).

Written by Cursor Bugbot for commit 69b0eff. This will update automatically on new commits. Configure here.

Copy link
Member

@Kylejeong2 Kylejeong2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS version lgtm other than the fact that you can't use advanced stealth/proxies on a non-paid plan.

Also all of our templates are in both python/TS

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

BROWSERBASE_API_KEY="YOUR_BROWSERBASE_API_KEY"
# Pass your preferred LLM API key (choose a model for your provider in the Stagehand constructor)
OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
GOOGLE_API_KEY="YOUR_GOOGLE_API_KEY"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Env variable name mismatch breaks API key loading

High Severity

The .env.example defines GOOGLE_API_KEY, but the code on line 54 of index.ts reads process.env.GOOGLE_GENERATIVE_AI_API_KEY. The README correctly tells users to set GOOGLE_GENERATIVE_AI_API_KEY, but anyone who copies .env.example (as instructed in the quickstart step 3) and fills in their key under GOOGLE_API_KEY will end up with an undefined API key, causing the Stagehand model configuration to fail at runtime.

Additional Locations (1)

Fix in Cursor Fix in Web

// Always call stagehand.close() when done. This gracefully ends the Browserbase
// session and releases the cloud browser resources. Forgetting to close will
// leave the session running and continue consuming your plan's session minutes.
await stagehand.close();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing try-finally leaks Browserbase session on error

Medium Severity

After stagehand.init() on line 80, any error thrown before line 214 (e.g., during agent execution, extraction, or navigation) will skip stagehand.close(). The outer .catch handler logs and exits but never closes the session, leaving the Browserbase browser running and consuming plan minutes. Every other comparable example in this repo wraps the body in try-finally to guarantee cleanup.

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants