Skip to content

Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.

Do not download images

Magnus Müllerc69dd517ce23
diff --git a/browser_use/browser/watchdogs/downloads_watchdog.py b/browser_use/browser/watchdogs/downloads_watchdog.py
index 34658ba1e..59fb57136 100644
--- a/browser_use/browser/watchdogs/downloads_watchdog.py
+++ b/browser_use/browser/watchdogs/downloads_watchdog.py
@@ -340,6 +340,28 @@ class DownloadsWatchdog(BaseWatchdog):
content_disposition = headers.get('content-disposition', '').lower()
is_download_attachment = 'attachment' in content_disposition
+ # Filter out image/video/audio files even if marked as attachment
+ # These are likely resources, not intentional downloads
+ unwanted_content_types = [
+ 'image/', 'video/', 'audio/',
+ 'text/css', 'text/javascript', 'application/javascript',
+ 'application/x-javascript', 'text/html', 'application/json',
+ 'font/', 'application/font', 'application/x-font'
+ ]
+ is_unwanted_type = any(content_type.startswith(prefix) for prefix in unwanted_content_types)
+ if is_unwanted_type:
+ return
+
+ # Check URL extension to filter out obvious images/resources
+ url_lower = url.lower().split('?')[0] # Remove query params
+ unwanted_extensions = [
+ '.jpg', '.jpeg', '.png', '.gif', '.webp', '.svg', '.ico',
+ '.css', '.js', '.woff', '.woff2', '.ttf', '.eot',
+ '.mp4', '.webm', '.mp3', '.wav', '.ogg'
+ ]
+ if any(url_lower.endswith(ext) for ext in unwanted_extensions):
+ return
+
# Only process if it's a PDF or download
if not (is_pdf or is_download_attachment):
return