'Extract user data from profile HTML.'

def extract_data(self, html):

    data = {}
    parsed = pq(html)
    username_elem = parsed.find(u'h1.user-title    span.nickname')[0]
    data[u'username'] = username_elem.text
    fullname_elems = parsed.find(u'h1.user-title    span.fn')
    if fullname_elems:
        data[u'fullname'] = fullname_elems[0].text
    if parsed.find(u'ul.user-info'):
        for (cls, name) in ((u'title', u'title'), (u'org', u'organization'), (u'loc', u'location'), (u'irc', u'irc_nickname')):
            elem = parsed.find((u'ul.user-info    li.%s' % cls))
            if elem:
                if (cls == u'irc'):
                    raw = elem[0].text
                    data[name] = raw.replace(u'IRC:    ', u'')
                else:
                    data[name] = elem[0].text
    tags_divs = parsed.find(u'div.user-tags')
    for tag_div in tags_divs:
        h2 = tag_div.find(u'h2')
        if (u'Interests' in h2.text):
            tag_type = u'interest'
        else:
            assert (u'Expertise' in h2.text)
            tag_type = u'expertise'
        tags = sorted([tag.text for tag in tag_div.cssselect(u'span')])
        data[tag_type] = tags
    if self.social:
        socials = (u'twitter', u'github', u'stackoverflow', u'linkedin', u'mozillians', u'facebook')
        for social in socials:
            cssselect = (u'ul.user-links    li.%s    a' % social)
            social_elem = parsed.find(cssselect)
            if social_elem:
                social_href = self.decode_href(social_elem.attr(u'href'))
                data[(u'%s_url' % social)] = social_href
    since_elem = parsed.find(u'div.user-since    time')
    raw_date_joined = since_elem.attr(u'datetime')
    date_joined = dateutil.parser.parse(raw_date_joined)
    data[u'date_joined'] = date_joined.replace(tzinfo=None)
    return data
