Git Product home page Git Product logo

maga's Introduction

Maga

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

maga's People

Contributors

drxzcl avatar helloqiu avatar whtsky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

maga's Issues

name?

how to get the name (and maybe size) of the torrent when a hash is found?

which becoder can I use?

here is the error:


Traceback (most recent call last):
  File "example.py", line 1, in <module>
    from maga import Maga
  File "C:\Users\o\Desktop\simDHT-master\maga.py", line 10, in <module>
    from bencoder import bencode, bdecode
ImportError: cannot import name 'bencode'

thx

scrapes non-torrent SHA1s?

Hey! Awesome project, nice implementation.

Looking at the "infohashes" returned and they don't seem to be for torrents - any thoughts on this observation?

example hashes:

020186F81E4C35B5D25A4346C1D3D5774D7D87EB
71B71A3DDDC15C5D6BD6C6E4EEBE7D8265500FAA
4FA3E3EC44A4BAD604FEF4574A15F8E35DCC084E
B2F21752B40B8E17135304E7920AA7A60E1CBF4E
0EAB04C060180861B93113F15F909AB783B382B3
4E014C2B5EB9A0CC33AB9E42E6ADFEEE4D48BBE8
A22904175F1A0FEC3BCD64FAD2B91FCADFAE33FE
280886E8887488258471E9E557E857E33E695393
FB3D17270AAEEF8EDD7BC8AD6409B91593F78632
59D1C711C89DB26A4924B72040DCB6AAB6E303F5
79626F0B9B7DE4562B1CD830CE86BF81C589E0EA
51B9D227F9B014687EDFA8E8F545B2B7C76575AC
2E4A1FA169F9764EEF21829000322D63B148E8CF
A2EF172768A04C5D091F42DB4C23FBEC6EAE9CF8
D1D72C228A0B2BEBE6CADC477A2806B1D97C33B2
AE122DC9B3DB4E6C57440894957B18A3E92BDD2D
0F1A00B0D7FBB5ECDD21F6B5CBEC852C93DAC1BA
A806E8EEA46898F0766C17262B95B839C877B7DE
232A5C2AA2FBC6B7B787F0949A80589A532EC958
6F91B6D8BFFB439764377205E4B9835785F358F6
7CE30C50410B21DE0829897326259D5586BD047F
7C31D6BB1B429F73500064CC2688DEA32153353C
A10FB893C981954BD845D3A76DB8E1FDC53CB89D
CEAD6932E5D27B63F56B40E8E4EBE7FB5B5AF5FA

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.