scrapy-splash与splash

splash介绍

splash是一个针对js的渲染服务,它内置了一个浏览器和http接口,基于python3和twisted引擎,所以是可以异步处理任务。

安装

https://splash.readthedocs.io/en/stable/install.html

只有mac和linux支持,也可以通过docker安装。

使用docker pull scrapinghub/splash

使用docker run -p 8050:8050 -p 5023 scrapinghub/splash运行镜像

使用

基础使用

使用浏览器访问http://localhost:8050

scrapy-splash

scrapy集成selenium

selenium在scrapy中无界面的解决方案(linux)

  • 安装环境

pip install pyvirtualdisplay

  • 安装报错解决

apt-get install xvfb
pip install xvfbwrapper

  • 使用实例
    1
    2
    3
    4
    5
    from pyvirtualdisplay import Display
    display = Display(visible=0, size=(800,600))
    display.start()
    browser = webdiver.Chrome()
    browser.get()

selenium grid

slinter

煌金 wechat
扫描关注公众号,回复「1024」获取为你准备的特别推送~
  • 本文作者: 煌金 | 微信公众号【咸鱼学Python】
  • 本文链接: http://www.xianyucoder.cn/2019/04/06/scrapy-splash_and_splash/
  • 版权声明: 本博客所有文章除特别声明外,均采用 许可协议。转载请注明出处!
  • 并保留本声明和上方二维码。感谢您的阅读和支持!