avoid "Uncaught RangeError: Maximum call stack size exceeded" compiling outlinks

This commit is contained in:
Noah Levitt 2016-08-04 17:33:06 -07:00
parent 7734399a22
commit 20f9934dd9
2 changed files with 7 additions and 5 deletions

View File

@ -301,17 +301,19 @@ class Browser:
self._behavior = None
OUTLINKS_JS = """
var compileOutlinks = function(frame) {
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]) { // sometimes undefined (why?)
outlinks = outlinks.concat(compileOutlinks(frame.frames[i]));
if (frame.frames[i] && !__brzl_framesDone.has(frame.frames[i])) {
outlinks = outlinks.concat(__brzl_compileOutlinks(frame.frames[i]));
}
}
return outlinks;
}
compileOutlinks(window).join(' ');
__brzl_compileOutlinks(window).join(' ');
"""
def _chain_chrome_messages(self, chain):

View File

@ -32,7 +32,7 @@ def find_package_data(package):
setuptools.setup(
name='brozzler',
version='1.1b5.dev66',
version='1.1b5.dev67',
description='Distributed web crawling with browsers',
url='https://github.com/internetarchive/brozzler',
author='Noah Levitt',