Stagehand agent to extract screenshots of Linkedin banner images#62
Stagehand agent to extract screenshots of Linkedin banner images#62
Conversation
Kylejeong2
left a comment
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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)
| // 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(); |
There was a problem hiding this comment.
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.


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-screenshotexample that takes a company name, uses a Stagehand CUA agent to find the company’s LinkedIn page via Google, then usesstagehand.extractto grab the banner image URL and saves a clipped screenshot of the image toimages/.Includes an
.env.exampleand 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.