GithubHelp home page GithubHelp logo

doubanmovies's Introduction

代理池+进程池+异步多线程(Redis)爬取豆瓣评分前500的电影

代码逻辑

  1. 爬取豆瓣高分top500,每页20条

  2. 进程池 + 异步多线程。

    开启进程池,每个进程下开启两个线程,一个爬取电影列表页,提取每部电影ID并存进Redis;另一个线程从Redis列表中取出ID,拼接成电影详情页URL,爬取、解析并存进MySQL数据库中,实现异步多线程。

  3. 基于Redis有序集合,维护一个代理IP池。

    爬取免费代理IP并赋予初始得分score,每次从得分最高的IP中随机取出一个进行健康测试,如果不能使用则减一分直至为0时从Redis中剔除。

环境

Redis,MySQL,Python3.5+

requirements,个人使用的版本,仅作参考。

redis>=3.2.1
requests>=2.21.0
lxml>=4.2.5
pymysql>=0.9.3

参考

代理池:https://github.com/merelysmile/ProxyPool

代理池的实现借鉴了 崔庆才老师的项目,在此基础上更新了免费代理网站的爬取规则。

代理IP的测试与使用,参考了 utopianist的项目

doubanmovies's People

Contributors

destroyedcount avatar

Watchers

James Cloos 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.