Reading Messages on Poloniex Trollbox with Python autbahn or other socket module?

前端 未结 4 1503
一生所求
一生所求 2021-01-21 17:50

Poloniex doesn\'t return every message to my socket. I read the messages with the following code and sometimes I get continuous message numbers, but sometimes there are like 10

4条回答
  •  悲哀的现实
    2021-01-21 18:19

    You can check this code here i made: Here. It uses Beautiful soup and dryscape. It gets it by getting on Poloniex website and waiting for some time, then gathers data from website, in our case the Trollbox. I also tried with autobahn, and this is what i got, but it looks exactly like your code, so there would probably be no improvement.

    from twisted.internet.defer import inlineCallbacks
    from autobahn.twisted.wamp import ApplicationSession,ApplicationRunner
    
    #prints recieved message
    def tamperMessage(message):
           print message
    
    
    
    class MyComponent(ApplicationSession):
    
    @inlineCallbacks
    def onJoin(self, details):
        print("session joined")
        #gets message and calls tamperMessage function
        def gotMessage(type, messageNumber, username, message, reputation):
            tamperMessage(message)
    
        # 1. subscribe to a topic so we receive events
        try:
            yield self.subscribe(gotMessage,u'trollbox')
       except Exception as e:
           print("could not subscribe to topic:")
    
    runner = ApplicationRunner(url=u"wss://api.poloniex.com", realm=u"realm1")
    

提交回复
热议问题