normanr / yahoo-transport

Yahoo! transport for Jabber written in Python

This URL has Read+Write access

yahoo-transport / avatar.py
100644 22 lines (20 sloc) 0.618 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import httplib,sys,traceback
 
def getavatar(aid, debug):
    #the aid value is the Avatar ID. This is given in tag 197
    conn = httplib.HTTPConnection("img.msg.yahoo.com")
    if debug: conn.debuglevel=3
    try:
        conn.request("GET","/avatar.php?yids=%s"%aid)
        r1 = conn.getresponse()
    except:
        if debug: traceback.print_exc()
        sys.exc_clear()
        return None
    #print r1.status, r1.reason
    if r1.status == 200:
        try:
            return r1.read()
        except TypeError:
            if debug: traceback.print_exc()
            sys.exc_clear()
            return None