Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A DHT crawler framework using asyncio.

Project description

A DHT crawler framework using asyncio.

Usage

from maga import Maga

import logging
logging.basicConfig(level=logging.INFO)


class Crawler(Maga):
    async def handler(self, infohash, addr):
        logging.info(addr)
        logging.info(infohash)


# Or, if you want to have more control

class Crawler(Maga):
    async def handle_get_peers(self, infohash, addr):
        logging.info(
            "Receive get peers message from DHT {}. Infohash: {}.".format(
                addr, infohash
            )
        )

    async def handle_announce_peer(self, infohash, addr, peer_addr):
        logging.info(
            "Receive announce peer message from DHT {}. Infohash: {}. Peer address:{}".format(
                addr, infohash, peer_addr
            )
        )


crawler = Crawler()
# Set port to 0 will use a random available port
crawler.run(port=0)

ChangeLog

Version 3.0.0

  • Add peer_addr param to handle_announce_peer method.
  • Don’t raise NotImplementedError on handler

Version 2.0.1

  • Don’t fail when signals are not implemented.( #3 )

Version 2.0.0

  • Add handle_get_peers, handle_announce_peer method.
  • Add addr param to handler

Project details


Download files

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

Files for Maga, version 3.0.0
Filename, size File type Python version Upload date Hashes
Filename, size Maga-3.0.0-py2.py3-none-any.whl (4.9 kB) File type Wheel Python version 3.5 Upload date Hashes View hashes
Filename, size Maga-3.0.0.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View hashes
Filename, size Maga-3.0.0.zip (7.2 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page