'Extracts sponsors from bill page.'

def extract_sponsors(self, bill, doc, chamber):

    sponsors = doc.xpath('//div[@class="author"]/ul/li/a/text()')
    for (index, sponsor) in enumerate(sponsors):
        if (index == 0):
            sponsor_type = 'primary'
            is_primary = True
        else:
            sponsor_type = 'cosponsor'
            is_primary = False
        sponsor_name = sponsor.strip()
        bill.add_sponsorship(sponsor_name, classification=sponsor_type, entity_type='person', primary=is_primary)
    return bill
