Skip to content

Comments

Local browser instance and profile selection#13

Merged
hrithikkoduri merged 2 commits intomainfrom
feature-LocalBrowserInstance
Feb 13, 2025
Merged

Local browser instance and profile selection#13
hrithikkoduri merged 2 commits intomainfrom
feature-LocalBrowserInstance

Conversation

@hrithikkoduri
Copy link
Owner

@hrithikkoduri hrithikkoduri commented Jan 31, 2025

Local Chrome Browser Instance

This pull request introduces several key updates and improvements across multiple files, primarily aimed at enhancing browser automation functionality within the backend application. The changes streamline browser setup, improve maintainability, and introduce a new modular browser handling approach.

Key Changes

1️⃣ Updated .gitignore

  • Added new ignored files (screenshot.jpg) to prevent unnecessary tracking of generated outputs.

2️⃣ Refactored Browser Setup in backend/app/init.py

  • Removed setup_browser_2, consolidating the browser setup under setup_browser.
  • This helps simplify imports and maintain a cleaner API.

3️⃣ Enhancements in backend/app/main.py

  • Refactored /setup-browser endpoint function:
  • Renamed it to setup_browser_endpoint for clarity.
  • Removed setup_browser_2 and streamlined handling of Google-specific requests.
  • Improved session cleanup before initializing new browser instances.

4️⃣ Major Cleanup in backend/app/webrover.py

  • Removed setup_browser_2 in favor of the new WebRoverBrowser class.
  • Simplified browser automation by delegating browser initialization to webrover_browser.py.
  • Reduced unnecessary browser options, making automation more efficient and human-like.

5️⃣ New Browser Handling Module: backend/app/webrover_browser.py

  • Introduced a new class WebRoverBrowser that:
  • Manages Chrome connections via remote debugging.
  • Supports profile persistence, proxy settings, and anti-detection measures.
  • Implements optimized page loading (blocking ads, analytics scripts, etc.).
  • Includes retry mechanisms for better stability.

Impact & Benefits

✅ Code Simplification: Removes redundant browser functions (setup_browser_2) and consolidates logic.
✅ Enhanced Browser Control: Introduces a dedicated WebRoverBrowser class for better automation & debugging.
✅ More Reliable API Calls: Improves error handling and streamlines browser session management.
✅ Improved Performance: Blocks unnecessary resources (images, analytics) for faster browsing.

@hrithikkoduri
Copy link
Owner Author

hrithikkoduri commented Jan 31, 2025

Addressed PR #9

@hrithikkoduri
Copy link
Owner Author

@govindsinghrawat Can you please test this on you end too?

@govindsinghrawat
Copy link
Contributor

@govindsinghrawat Can you please test this on you end too?

LGTM @hrithikkoduri

@hrithikkoduri hrithikkoduri merged commit 7ac0e69 into main Feb 13, 2025
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