From 70dc6fe77e1457c03adf22ccff52acdcc8c00afa Mon Sep 17 00:00:00 2001 From: zt2370 Date: Thu, 10 Apr 2025 21:33:28 +0800 Subject: [PATCH] Add small features to scrapybara computer --- .env.example | 3 ++- cli.py | 2 +- computers/scrapybara.py | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 43032b5..2189521 100644 --- a/.env.example +++ b/.env.example @@ -6,4 +6,5 @@ OPENAI_ORG = "org-123" BROWSERBASE_API_KEY="00000000-0000-0000-0000-000000000000" BROWSERBASE_PROJECT_ID="bb_live_00000000-00000" -SCRAPYBARA_API_KEY="scrapy-123" \ No newline at end of file +SCRAPYBARA_API_KEY="scrapy-123" +SCRAPYBARA_AUTH_STATE_ID="00000000-0000-0000-0000-000000000000" \ No newline at end of file diff --git a/cli.py b/cli.py index 891f3fb..d3e97ec 100644 --- a/cli.py +++ b/cli.py @@ -73,7 +73,7 @@ def main(): items = [] - if args.computer in ["browserbase", "local-playwright"]: + if args.computer in ["browserbase", "local-playwright", "scrapybara-browser"]: if not args.start_url.startswith("http"): args.start_url = "https://" + args.start_url agent.computer.goto(args.start_url) diff --git a/computers/scrapybara.py b/computers/scrapybara.py index 497c6f6..09b6f42 100644 --- a/computers/scrapybara.py +++ b/computers/scrapybara.py @@ -52,6 +52,9 @@ def __enter__(self): for domain in BLOCKED_DOMAINS ] self.instance = self.client.start_browser(blocked_domains=blocked_domains) + auth_state_id = os.getenv("SCRAPYBARA_AUTH_STATE_ID") + if auth_state_id: + self.instance.authenticate(auth_state_id=auth_state_id) print("Scrapybara browser started ₍ᐢ•(ܫ)•ᐢ₎") print( f"You can view and interact with the stream at {self.instance.get_stream_url().stream_url}"