passing from sleekxmpp to slixmpp AttributeError: '_asyncio.Future' object has no attribute 'find_all'

passing from sleekxmpp to slixmpp AttributeError: '_asyncio.Future' object has no attribute 'find_all'

我正在使用 slixmpp 我已经在 sleekxmpp 中完成了这些并试图传递给 slixmpp

for i in results.find_all('.//{jabber:x:data}value'): AttributeError: '_asyncio.Future' object has no attribute 'find_all'

#Create iq Stanza
resp = self.Iq()
resp['type'] = 'set'
resp['to'] = 'search.michaela-pc'
resp['from'] =  self.jid 
resp['id'] = 'search_result'
#Service discovery stanza for getting all users
resp.append(ET.fromstring("<query xmlns='jabber:iq:search'>\
                         <x xmlns='jabber:x:data' type='submit'>\
                            <field type='hidden' var='FORM_TYPE'>\
                                <value>jabber:iq:search</value>\
                            </field>\
                            <field var='Username'>\
                                <value>1</value>\
                            </field>\
                            <field var='search'>\
                                <value>*</value>\
                            </field>\
                        </x>\
                    </query>"))
try:
    results = resp.send()
    # Extract info from recived stanza
    for i in results.find_all('.//{jabber:x:data}value'): 
        if ((i.text != None) and ("@" in i.text)):
            print(i.text)
except IqError as e:
    print("Could not get users")
except IqTimeout:
    print("Server did no respond")

使用 Slixmpp Iq.send() doesn't block anymore,但 returns 一个 Future

make it blocking,你需要像这样从 Future 屈服:

results = yield from resp.send()
for i in results.find_all('.//{jabber:x:data}value'): 
    if ((i.text != None) and ("@" in i.text)):
        print(i.text)