Python開發的網頁圖片下載工具:crawl-me

jopen 10年前發布 | 21K 次閱讀 crawl-me 網絡爬蟲

crawl-me

crawl-me是一個基于plugin的輕量級快速網頁圖片下載工具。crawl-me通過簡單的命令行就可以用你想要的方式下載各個網站下的圖片。目前暫時只支持gamersky(游明星空), pixiv(P站),更多plugin盡請期待,歡迎為它添加新的plugin。

Features

  • 支持Http range-headers 并發分段下載,速度更快
  • 支持添加plugin自定義新的行為,例如添加對微博的支持

Available plugins

  • pixiv : P站圖片下載插件,支持下載某P主所有作品
  • gamersky : 游明星空圖庫下載插件,支持下載游民星空圖庫中的某一個專題的所有圖片

Installation

通過git安裝

1. Ubuntu下安裝

由于代碼依賴了pyquery,安裝前請確保libxslt-devel libxml2-devel已被安裝

    sudo apt-get install libxml2-dev
    sudo apt-get install libxslt1-dev 

然后請確保安裝了[setuptools](https://pypi.python.org/pypi/setuptools#downloads "setuptools"), Ubuntu下你可以:

    sudo apt-get install python-setuptools

然后從github clone source到本地

    $ git clone https://github.com/nyankosama/crawl-me.git
    $ cd crawl-me/
    $ sudo python setup.py install

2. Windows下安裝

首先你需要安裝[python2.7](https://www.python.org/download/releases/2.7.7/)和[pip](https://pip.pypa.io/en/latest/installing.html),python2.7可以通過windows installer安裝。安裝pip首先下載[get-pip.py](https://bootstrap.pypa.io/get-pip.py), 然后執行下面命令。

    python get-pip.py

然后,你需要安裝pyquery的所依賴的lxml,選擇對應的[lxml installer](https://pypi.python.org/pypi/lxml/3.3.5#downloads)下載并安裝

最后從github clone 到本地

    $ git clone https://github.com/nyankosama/crawl-me.git
    $ cd crawl-me/
    $ sudo python setup.py install

在使用crawl-me之前,請確保把{$python-home}/Scripts/ 加入Windows環境變量中

Usage

Examples

  1. 下載gamersky下的http://www.gamersky.com/ent/201404/352055.shtml 的第1頁到第10頁的所有圖片到當前目錄的gamersky-crawl文件夾下

    crawl-me gamersky http://www.gamersky.com/ent/201404/352055.shtml ./gamersky-crawl 1 10
  2. 一鍵下載P站藤原桑的所有作品到pixiv-crawl文件夾(藤原桑的id是27517)

    crawl-me pixiv 27517 ./pixiv-crawl <your pixiv loginid> <your password>

Command line options

  1. general help

    $ crawl-me -h    
    
    usage: crawl-me [-h] plugin
    
    positional arguments:
        plugin      plugin the crawler uses
    
    optional arguments:
        -h, --help  show this help message and exit
    
    available plugins:
    ----gamersky
    ----pixiv
  2. gamersky

    $ crawl-me gamersky -h
    
    usage: crawl-me [-h] plugin authorId savePath pixivId password
    
    positional arguments:
        plugin      plugin the crawler uses
        authorId    the author id you want to crawl
        savePath    the path where the imgs ars saved
        pixivId     your pixiv login id
        password    your pixiv login password
    
    optional arguments:
        -h, --help  show this help message and exit
  3. pixiv

    $ crawl-me pixiv -h
    
    usage: crawl-me [-h] plugin authorId savePath pixivId password
    
    positional arguments:
        plugin      plugin the crawler uses
        authorId    the author id you want to crawl
        savePath    the path where the imgs ars saved
        pixivId     your pixiv login id
        password    your pixiv login password
    
    optional arguments:
        -h, --help  show this help message and exit

項目主頁:http://www.baiduhome.net/lib/view/home/1402450658681

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!