-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EvalError: Refused to evaluate a string as JavaScript #62
Comments
AFAIK the only way is to strip CSP headers using a proxy in front of Splash. See scrapinghub/splash#313. |
Thanks @kmike , it's good to know that this is a known issue :) |
I was looking at the code and trying to figure out where would I add pcall, a bit confused there, could you point me towards that please. I would like to skip this error and continue with the rendering without the js script. Would it have to be in the Splash code (where the lua script is getting called)? Thanks. |
@nehakansal I think |
Thanks. I tried that earlier but it didnt work. I will try further. |
Requests may fail completely due to failure to execute javascript headless horsemen scripts:
[scrapy_splash.middleware] WARNING: Bad request to Splash: {'description': 'Error happened while executing Lua script', 'error': 400, 'info': {'line_number': 70, 'error': 'JavaScript error: EvalError: Refused to evaluate a string as JavaScript because \'unsafe-eval\' is not an allowed source of script in the following Content Security Policy directive: "script-src \'self\' https://*.twimg.com https://*.twitter.com https://static.ads-twitter.com".', 'message': 'Lua error: [string "function get_arg(arg, default)..."]:70: JavaScript error: EvalError: Refused to evaluate a string as JavaScript because \'unsafe-eval\' is not an allowed source of script in the following Content Security Policy directive: "script-src \'self\' https://*.twimg.com https://*.twitter.com https://static.ads-twitter.com".\n', 'source': '[string "function get_arg(arg, default)..."]', 'type': 'LUA_ERROR'}, 'type': 'ScriptError'}
Line 70 is this one:
undercrawler/undercrawler/directives/headless_horseman.lua
Line 70 in 710b7f5
It's possible to skip the error with pcall: https://www.lua.org/pil/8.4.html, but maybe there is a way to still execute js on the page?
The text was updated successfully, but these errors were encountered: