由于scrapy爬虫框架可以对页面进行动态js渲染,其中有两种工具:splash & selenium。
selenium通过webdriver模拟对页面的访问,但是由于某些网站的服务器响应问题,可能存在一些爬取效率问题。需要测试一些网页等待时间,这个等待时间还有待测试得出最佳的标准值。
并且selenium是一种阻塞式对页面进行访问的。所以先转向splash的方法,但是就上面 'url' 网页的渲染存在无法渲染动态js页面的情况。通过参考官方文档,但是并没有发现问题根源所在,只是一些就splash服务的属性和方法的介绍。
function main(splash, args)
splash.js_enabled = true
splash.resource_timeout = 50
splash.images_enabled = false
assert(splash:go(args.url))
assert(splash:wait(8))
return { html = splash:html(),
har = splash:har(),
png = splash:png()
}
end
运行结果页面:
原网页显示是文书详细内容。
希望各路大佬,有想法的可以在下方评论交流。