http://blitiri.com.ar/p/msnlib/
This is an opensource Python implementation for the MSN messenger protocol version 8.
The base is a library (called msnlib), which uses a non-blocking callback scheme.
库能用,不过文档一无所有,演示代码也不清晰,和tk写的图像界面混在一起.
不过能用就好.
import socket
import select
import time
import msnlib
import msncb
def void(s): pass
msnlib.debug = msncb.debug = void
def msn_friend_list(email,password):
m = msnlib.msnd()
m.cb = msncb.cb()
m.email = email.strip()
m.pwd = password.strip()
m.encoding = 'utf-8'
try:
m.login()
m.sync()
except:
return False
m.change_status('invisible')
begin_time = time.time()
users = set()
while 1:
fds = m.pollable()
infd = fds[0]
outfd = fds[1]
fds = select.select(infd, outfd, [], 0)
for i in fds[0] + fds[1]:
try:
m.read(i)
except ('SocketError', socket.error), err:
if i != m:
m.close(i)
merge_users=users|set(m.users.keys())
if len(users) == len(merge_users):
end_time = time.time()
if len(users):
if end_time-begin_time >= 2:
break
elif end_time-begin_time >= 3:
break
time.sleep(0.05)
else:
users = merge_users
begin_time=time.time()
result={}
for i in users:
result[i]=m.users[i].nick
return result