Open BiatuAutMiahn opened 5 years ago
I have a similar bug although I don't know if its related.
await self.page.evaluate('''
await new Promise((resolve, reject) => {
var totalHeight = 0;
var distance = 100;
var timer = setInterval(() => {
var scrollHeight = document.body.scrollHeight;
window.scrollBy(0, distance);
totalHeight += distance;
if(totalHeight >= scrollHeight){
clearInterval(timer);
resolve();
}
}, 100);
});
'''
)
Exception:
File "/Users/severinbuhler/git/ecom_scraper_puppeter/crawler/scraper.py", line 47, in request
await self._scroll_to_bottom()
File "/Users/severinbuhler/git/ecom_scraper_puppeter/crawler/scraper.py", line 16, in _scroll_to_bottom
return await self.page.evaluate(
File "/Users/severinbuhler/git/ecom_scraper_puppeter/venv/lib/python3.8/site-packages/pyppeteer/page.py", line 1158, in evaluate
return await frame.evaluate(pageFunction, *args, force_expr=force_expr)
File "/Users/severinbuhler/git/ecom_scraper_puppeter/venv/lib/python3.8/site-packages/pyppeteer/frame_manager.py", line 294, in evaluate
return await context.evaluate(
File "/Users/severinbuhler/git/ecom_scraper_puppeter/venv/lib/python3.8/site-packages/pyppeteer/execution_context.py", line 54, in evaluate
handle = await self.evaluateHandle(
File "/Users/severinbuhler/git/ecom_scraper_puppeter/venv/lib/python3.8/site-packages/pyppeteer/execution_context.py", line 113, in evaluateHandle
raise ElementHandleError('Evaluation failed: {}'.format(
pyppeteer.errors.ElementHandleError: Evaluation failed: SyntaxError: Unexpected token new
Process finished with exit code 1
Here is my script:
For some reason, when running the evaluate on the "BillFunc" script, I get this error:
I have tried to debug it many times, running the script in the chrome console manually provides the result, however the Evaluate fails. And it seems to fail on the nested function, cause as soon as I take the nested function out...it works again but does not provide the desired result.