From 1c5c9417d2f8be63b32ded6ac91d8ba4d713ee9a Mon Sep 17 00:00:00 2001 From: Noah Levitt Date: Thu, 25 Aug 2016 13:10:30 -0700 Subject: [PATCH] avoid "Uncaught TypeError: Cannot read property 'querySelectorAll' of undefined" from outlinks script --- brozzler/browser.py | 12 +++++++----- setup.py | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/brozzler/browser.py b/brozzler/browser.py index 55212c7..92e3479 100644 --- a/brozzler/browser.py +++ b/brozzler/browser.py @@ -304,11 +304,13 @@ class Browser: var __brzl_framesDone = new Set(); var __brzl_compileOutlinks = function(frame) { __brzl_framesDone.add(frame); - var outlinks = Array.prototype.slice.call( - frame.document.querySelectorAll('a[href]')); - for (var i = 0; i < frame.frames.length; i++) { - if (frame.frames[i] && !__brzl_framesDone.has(frame.frames[i])) { - outlinks = outlinks.concat(__brzl_compileOutlinks(frame.frames[i])); + if (frame && frame.document) { + var outlinks = Array.prototype.slice.call( + frame.document.querySelectorAll('a[href]')); + for (var i = 0; i < frame.frames.length; i++) { + if (frame.frames[i] && !__brzl_framesDone.has(frame.frames[i])) { + outlinks = outlinks.concat(__brzl_compileOutlinks(frame.frames[i])); + } } } return outlinks; diff --git a/setup.py b/setup.py index c8da234..036d336 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ def find_package_data(package): setuptools.setup( name='brozzler', - version='1.1b6.dev77', + version='1.1b6.dev78', description='Distributed web crawling with browsers', url='https://github.com/internetarchive/brozzler', author='Noah Levitt',