GithubHelp home page GithubHelp logo

zspider's Introduction

ZSpider

基本功能

zspider.py -u url -t thradNumber -d deep -l loglevel(1-5) -k keyword --model downloadModel(0/1) --dbfile dbName --testself

参数说明

-u 指定爬虫开始地址

-t 指定线程池大小,多线程爬取页面,可选参数,默认10

-d 指定爬虫深度

-l 日志记录文件记录详细程度,数字越大记录越详细,可选参数,默认zspider.log

-k 页面内的关键词,获取满足该关键词的网页,可选参数,默认为所有页面

--model 下载模式,0为静态下载,1为动态下载

--dbfile 存放结果数据到指定的数据库(sqlite)文件中

--testself 程序自测,可选参数

模块使用

  • 下载模块: requests 、splinter 、phantomjs

  • 解析模块: lxml 、urlparse 、hashlib 、re

  • 存储模块: sqlite3

  • 线程池模块: threading

  • 其它模块: Queue 、optparse 、logging

系统设计

核心模块

线程池模块

##测试

新浪首页: python zspider.py -u http://www.sina.com.cn -t 15 -d 3 -l 3

统计:

运行:

数据库:


测试最终结果:爬取新浪首页三级深度,共抓取页面958187个,耗时近7天。 测试达到要求的二级深度,但并未达到预期的三级深度(由于周末用笔记本打lol,结果以CPU温度过高死机而终)。

zspider's People

Contributors

zhjl120 avatar

Watchers

James Cloos avatar

Forkers

fungwan zhighest

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.