def make_request(
self, url, callback=None, meta=None, cls=None, **kwargs):
callback = callback or self.parse
cls = cls or (SplashRequest if self.use_splash else Request)
if self.use_splash:
settings = self.settings
splash_args = {
'lua_source': self.lua_source,
'js_source': self.js_source,
'run_hh': settings.getbool('RUN_HH'),
'return_png': settings.getbool('SCREENSHOT'),
'images_enabled': settings.getbool('IMAGES_ENABLED'),
}
for s in ['VIEWPORT_WIDTH', 'VIEWPORT_HEIGHT',
'SCREENSHOT_WIDTH', 'SCREENSHOT_HEIGHT']:
if self.settings.get(s):
splash_args[s.lower()] = self.settings.getint(s)
if self.settings.getbool('ADBLOCK'):
splash_args['filters'] = 'fanboy-annoyance,easylist'
if self.settings.getbool('FORCE_TOR'):
splash_args['proxy'] = 'tor'
kwargs.update(dict(
args=splash_args,
endpoint='execute',
cache_args=['lua_source', 'js_source'],
))
meta = meta or {}
meta['avoid_dup_content'] = True
return cls(url, callback=callback, meta=meta, **kwargs)
评论列表
文章目录