-
Notifications
You must be signed in to change notification settings - Fork 876
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
How to disable injectableTypes filter ? #299
Comments
HTML/XML like legacy documents are one of common cases. |
Here is a workaround:
|
Actually, these years we've found that many websites responded json text or html document without |
Honestly, the consideration mentioned above is reasonable, just lift these ambiguous cases up to developers, and do not put any assumption on unspecific cases. But the workaround here is extracted from source, and not stable. Therefore, a more beautiful solution is an option like this: new Crawler({
responseHeaderPatch: {
// TRUST ME, I know it's a real HTML document
'Content-Type': 'text/html'
},
callback : function (error, res, done) {
if(error){
console.log(error);
}else{
var $ = res.$;
}
}
}); And respectively warning:
|
It's really a good idea, but we have no response stage for plugin. We are planning to refactor crawler to middleware based architecture, then I think this is the best choice. |
The same situation with #243 ,there is no
ContentType
specified in my target response header, so, JQuery injection was broken, although it's valid HTML, and JQuery Injected successfully if I remove injectableTypes filter.How about provide an option to disable this restriction and log a warning message only, or just catch injection failure cases ?
The text was updated successfully, but these errors were encountered: