Skip to main content

icePick is a All in one Package library for easy Scraping

Project description

IcePick is a All in one Package library for easy Scraping


Concept

  • Lightweight Scraping Library

  • All in one Package library for easy Scraping

Requirements

  • Python 3.4 or later(not support 2.x)

  • MongoDB

Dependencies Libraries

  • aiohttp

  • beautifulsoup4

  • pymongo >= 3.0

  • nose

Usage

Scraping Flow,

Your Scraping Order(Order) -> Do Scraping(Picker) -> HTML Parse(Parser) -> Save in Database(Recorder)

Example

get a my repository filenames

import icePick

db = icePick.get_database('icePick_example', 'localhost')


class GithubRepoParser(icePick.Parser):
    def serialize(self):
        result = {
            "files": [],
        }

        for v in self.bs.find_all(class_="js-directory-link"):
            result['files'] += [v.text]
        return result


class GithubRepoRecorder(icePick.Recorder):
    struct = icePick.Structure(files=list())

    class Meta:
        database = db


class GithubRepoOrder(icePick.Order):
    recorder = GithubRepoRecorder
    parser = GithubRepoParser


def main():
    document = {
        'url': 'https://github.com/teitei-tk/ice-pick/tree/master',
        'ua': 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko',
    }

    print('---download start---')
    order = GithubRepoOrder(document.get('url'), document.get('ua'))
    picker = icePick.Picker([order])
    picker.run()
    print("---finish---")

if __name__ == "__main__":
    main()
>>> import icePick
>>> db = icePick.get_database('icePick_example', 'localhost')
>>> class GithubRepoRecorder(icePick.Recorder):
...     struct = icePick.Structure(files=list())
...     class Meta:
...         database = db
...
>>> records = GithubRepoRecorder.find()
>>> records[0].files
['example', 'icePick', 'tests', 'LICENSE', 'README.md', 'circle.yml', 'requirements.txt']
>>>

TODO

  • Crawling

  • Document

LICENSE

  • MIT

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

icePick-0.0.5.tar.gz (6.5 kB view details)

Uploaded Source

File details

Details for the file icePick-0.0.5.tar.gz.

File metadata

  • Download URL: icePick-0.0.5.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for icePick-0.0.5.tar.gz
Algorithm Hash digest
SHA256 af0a13832add144af80b231ed0ed7232aa5ca7b2d2f2b317cb2aa0e8ecab154b
MD5 a9d0a7cb3c7ecb8564415d4c114b5407
BLAKE2b-256 6dd5081c9f31bad2775a4b7cf7c9921ae0491df0c7ed7cf50830e4033feca89e

See more details on using hashes here.

Supported by

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