Skip to main content

A mini framework of image crawlers

Project description

PyPI Version Anaconda Version Python Version License

Introduction

Documentation: http://icrawler.readthedocs.io/

Try it with pip install icrawler or conda install -c hellock icrawler.

This package is a mini framework of web crawlers. With modularization design, it is easy to use and extend. It supports media data like images and videos very well, and can also be applied to texts and other type of files. Scrapy is heavy and powerful, while icrawler is tiny and flexible.

With this package, you can write a multiple thread crawler easily by focusing on the contents you want to crawl, keeping away from troublesome problems like exception handling, thread scheduling and communication.

It also provides built-in crawlers for popular image sites like Flickr and search engines such as Google, Bing and Baidu. (Thank all the contributors and pull requests are always welcome!)

Requirements

Python 2.7+ or 3.5+ (recommended).

Examples

Using built-in crawlers is very simple. A minimal example is shown as follows.

from icrawler.builtin import GoogleImageCrawler

google_crawler = GoogleImageCrawler(storage={'root_dir': 'your_image_dir'})
google_crawler.crawl(keyword='cat', max_num=100)

You can also configurate number of threads and apply advanced search options. (Note: compatible with 0.6.0 and later versions)

from icrawler.builtin import GoogleImageCrawler

google_crawler = GoogleImageCrawler(
    feeder_threads=1,
    parser_threads=2,
    downloader_threads=4,
    storage={'root_dir': 'your_image_dir'})
filters = dict(
    size='large',
    color='orange',
    license='commercial,modify',
    date=((2017, 1, 1), (2017, 11, 30)))
google_crawler.crawl(keyword='cat', filters=filters, max_num=1000, file_idx_offset=0)

For more advanced usage about built-in crawlers, please refer to the documentation.

Writing your own crawlers with this framework is also convenient, see the tutorials.

Architecture

A crawler consists of 3 main components (Feeder, Parser and Downloader), they are connected with each other with FIFO queues. The workflow is shown in the following figure.

  • url_queue stores the url of pages which may contain images

  • task_queue stores the image url as well as any meta data you like, each element in the queue is a dictionary and must contain the field img_url

  • Feeder puts page urls to url_queue

  • Parser requests and parses the page, then extracts the image urls and puts them into task_queue

  • Downloader gets tasks from task_queue and requests the images, then saves them in the given path.

Feeder, parser and downloader are all thread pools, so you can specify the number of threads they use.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

icrawler-0.6.3.macosx-10.9-x86_64.tar.gz (57.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

icrawler-0.6.3-py2.py3-none-any.whl (35.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file icrawler-0.6.3.macosx-10.9-x86_64.tar.gz.

File metadata

  • Download URL: icrawler-0.6.3.macosx-10.9-x86_64.tar.gz
  • Upload date:
  • Size: 57.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for icrawler-0.6.3.macosx-10.9-x86_64.tar.gz
Algorithm Hash digest
SHA256 d1670f6acab26e9f271ef307313f4e2c9cd1cf23a2e3da82aca8a39df5d4161c
MD5 7eb4229a02701470650ed7a40b032d68
BLAKE2b-256 5ac9a96925559139e3b085cdf92f5655ef918628a416e8a685e555fe3e0ca8cf

See more details on using hashes here.

File details

Details for the file icrawler-0.6.3-py2.py3-none-any.whl.

File metadata

  • Download URL: icrawler-0.6.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 35.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0.post20200518 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

File hashes

Hashes for icrawler-0.6.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8d166a0471dea563b9d0cf9af804d0efba2e28505ebe778d001d3f104f7ce1c4
MD5 559da75a9af7f8ec1eace93af963434f
BLAKE2b-256 89de71d154b1fe181ee1a4afae5d10451856ef4689b3fd72d93cc55f31d2886a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page