GithubHelp home page GithubHelp logo

wangy8961 / python3-concurrency Goto Github PK

View Code? Open in Web Editor NEW
56.0 2.0 25.0 16 KB

Python3爬虫系列的理论验证,首先研究I/O模型,分别用Python实现了blocking I/O、nonblocking I/O、I/O multiplexing各模型下的TCP服务端和客户端。然后,研究同步I/O操作(依序下载、多进程并发、多线程并发)和异步I/O(asyncio)之间的效率差别

Home Page: http://www.madmalls.com/blog/category/python3-spider/

Python 100.00%
python3 concurrency asyncio aiohttp requests threadpool processing futures progressbar coroutine

python3-concurrency's Introduction

Python aiohttp BeautifulSoup4 requests pymongo progressbar2

1. 爬虫系列

2. 使用方法

2.1 Server

为防止DDoS攻击,本次测试需要在本地搭建一个HTTP测试服务器,具体方法参考 Python3爬虫系列03 (实验) - 同步阻塞下载

2.2 Client

(1) 下载代码

[root@CentOS ~]# git clone https://github.com/wangy8961/python3-concurrency.git
[root@CentOS ~]# cd python3-concurrency/

(2) 准备虚拟环境

如果你的操作系统是Linux:

[root@CentOS python3-concurrency]# python3 -m venv venv3
[root@CentOS python3-concurrency]# source venv3/bin/activate

Windows激活虚拟环境的命令是: venv3\Scripts\activate

(3) 安装依赖包

如果你的操作系统是Linux:

(venv3) [root@CentOS python3-concurrency]# pip install -r requirements-linux.txt

如果你的操作系统是Windows(不会使用uvloop):

(venv3) C:\Users\wangy> pip install -r requirements-win32.txt

(4) 测试

依序下载:

(venv3) [root@CentOS python3-concurrency]# python sequential.py

多进程下载:

(venv3) [root@CentOS python3-concurrency]# python processpool.py

多线程下载:

(venv3) [root@CentOS python3-concurrency]# python threadpool.py

异步下载:

(venv3) [root@CentOS python3-concurrency]# python asynchronous.py

python3-concurrency's People

Contributors

wangy8961 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.