Python开发实例分享bt种子爬虫程序和种子解析

2019-10-06 15:48:52王振洲

                self.send_krpc(msg, address) 
                self.find_node(address, nid) 
            except KeyError: 
                pass 
        def get_peers_received(self, msg, address): 
            try: 
                infohash = msg["a"]["info_hash"] 
                neighbors = self.table.get_neighbors(infohash) 
                nid = msg["a"]["id"] 
                msg = { 
                    "t": msg["t"], 
                    "y": "r", 
                    "r": { 
                        "id": self.get_neighbor(infohash),  
                        "nodes": encode_nodes(neighbors) 
                    } 
                } 
                self.table.append(KNode(nid, *address)) 
                self.send_krpc(msg, address) 
                self.master.log(infohash) 
                self.find_node(address, nid) 
            except KeyError: 
                pass 
        def announce_peer_received(self, msg, address): 
            try: 
                infohash = msg["a"]["info_hash"]