From 26f900a4067454d4c7a1ad8c388d4a2c40b0b227 Mon Sep 17 00:00:00 2001 From: Ross Date: Tue, 14 Oct 2025 14:17:02 +0100 Subject: [PATCH] Enhance capture functionality to allow saving images regardless of domain filter when image capture is enabled --- scrapers/statdx_play_chrome.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/scrapers/statdx_play_chrome.py b/scrapers/statdx_play_chrome.py index eb9e88a..e9e11e8 100644 --- a/scrapers/statdx_play_chrome.py +++ b/scrapers/statdx_play_chrome.py @@ -45,7 +45,7 @@ def main(): parser.add_argument('--capture', action='store_true', help='Capture XHR/fetch requests and responses while the browser is open') parser.add_argument('--capture-output', default='xhr_captured', help='Directory to save captured XHRs') parser.add_argument('--capture-wait', type=float, default=6.0, help='Seconds to wait after reload for XHRs to complete when capture starts') - parser.add_argument('--capture-types', default='xhr,fetch,document', help='Comma-separated list of resource types to capture (e.g. xhr,fetch,document,image)') + parser.add_argument('--capture-types', default='xhr,fetch,document,image', help='Comma-separated list of resource types to capture (e.g. xhr,fetch,document,image)') args = parser.parse_args() os.makedirs(args.profile, exist_ok=True) @@ -98,10 +98,18 @@ def main(): logger.debug(f'Response: {resp.status} {resp.url}') try: req = resp.request - rtype = req.resource_type - if args.domain not in req.url: - return - if rtype not in capture_types: + rtype = (req.resource_type or '').lower() + + # Save images regardless of domain filter when image capture is enabled. + if rtype == 'image' and 'image' in capture_types: + allow_save = True + else: + # For non-image responses, enforce domain filter + if args.domain and args.domain not in req.url: + return + allow_save = rtype in capture_types + + if not allow_save: return ts = datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ')