Git Product home page Git Product logo

aiospider's Introduction

AioSpider

基于asyncio与aiohttpp的异步爬虫

百度贴吧异步爬虫

├── BaiduTeiba
│   ├── AioBaiduSpider.py    ------>异步爬虫
│   ├── PlainBaiduSpider.py  ------>普通爬虫
│   ├── ThreadBaiduSpider.py ------>多线程爬虫
│   ├── aio_post.json
│   ├── plain_post.json
│   └── thread_post.json
└── README.md

普通爬虫用于耗时上对比性能的区别

经过对比爬取5页各3次中所有帖子耗时如下:

多线程爬虫:

  • 帖子数量: 246 耗时:9.46秒
  • 帖子数量: 245 耗时:7.29秒
  • 帖子数量: 245 耗时:8.64秒

异步爬虫:

  • 帖子数量: 245 耗时:10.91秒
  • 帖子数量: 245 耗时:10.90秒
  • 帖子数量: 245 耗时:9.89秒

普通爬虫:

  • 帖子数量: 245 耗时:46.88秒
  • 帖子数量: 245 耗时:42.93秒
  • 帖子数量: 245 耗时:42.70秒

总结:

  • 多线程爬虫的效率较高
  • 异步爬虫(即:单线程协程)效率也高,而且在执行IO操作时会比多线略优,缺点:不能用于较多密集计算的场景下
  • 普通爬虫效率较低不能在大量的数据爬取的场景下使用,耗费时间/资源

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.