本文整理汇总了Python中pupa.scrape.Bill.extras['amendment']方法的典型用法代码示例。如果您正苦于以下问题:Python Bill.extras['amendment']方法的具体用法?Python Bill.extras['amendment']怎么用?Python Bill.extras['amendment']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pupa.scrape.Bill
的用法示例。
在下文中一共展示了Bill.extras['amendment']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scrape_bill
# 需要导入模块: from pupa.scrape import Bill [as 别名]
# 或者: from pupa.scrape.Bill import extras['amendment'] [as 别名]
def scrape_bill(self, row, session):
bill_id = row['LegislationDisplayCode']
amendment = None
substitute = None
if bill_id.count(' ') > 1:
if ' w/ ' in bill_id:
self.info('Found amended bill `{}`'.format(bill_id))
bill_id, amendment = bill_id.split(' w/ ')
# A bill can _both_ be amended and be substituted
if ' for ' in bill_id:
self.info("Found substitute to use instead: `{}`".format(bill_id))
substitute, bill_id = bill_id.split(' for ')
if amendment is None and substitute is None:
raise ValueError('unknown bill_id format: ' + bill_id)
bill_type = self.classify_bill(bill_id)
chamber = 'upper' if bill_id.startswith('S') else 'lower'
bill = Bill(identifier=bill_id,
legislative_session=session,
chamber=chamber,
title=row['LongTitle'],
classification=bill_type)
if row['Synopsis']:
bill.add_abstract(row['Synopsis'], 'synopsis')
if row['ShortTitle']:
bill.add_title(row['ShortTitle'], 'short title')
if row['SponsorPersonId']:
self.add_sponsor_by_legislator_id(bill, row['SponsorPersonId'], 'primary')
if substitute:
bill.extras['substitute'] = substitute
if amendment:
bill.extras['amendment'] = amendment
# TODO: Is there a way get additional sponsors and cosponsors, and versions/fns via API?
html_url = 'https://legis.delaware.gov/BillDetail?LegislationId={}'.format(
row['LegislationId']
)
bill.add_source(html_url, note='text/html')
html = self.lxmlize(html_url)
additional_sponsors = html.xpath('//label[text()="Additional Sponsor(s):"]'
'/following-sibling::div/a/@href')
for sponsor_url in additional_sponsors:
sponsor_id = sponsor_url.replace('https://legis.delaware.gov/LegislatorDetail?'
'personId=', '')
self.add_sponsor_by_legislator_id(bill, sponsor_id, 'primary')
cosponsors = html.xpath('//label[text()="Co-Sponsor(s):"]/'
'following-sibling::div/a/@href')
for sponsor_url in cosponsors:
sponsor_id = sponsor_url.replace('https://legis.delaware.gov/LegislatorDetail?'
'personId=', '')
self.add_sponsor_by_legislator_id(bill, sponsor_id, 'cosponsor')
versions = html.xpath('//label[text()="Original Text:"]/following-sibling::div/a/@href')
for version_url in versions:
media_type = self.mime_from_link(version_url)
version_name = 'Bill Text'
bill.add_version_link(version_name, version_url, media_type=media_type)
fiscals = html.xpath('//div[contains(@class,"fiscalNote")]/a/@href')
for fiscal in fiscals:
self.scrape_fiscal_note(bill, fiscal)
self.scrape_actions(bill, row['LegislationId'])
if row['HasAmendments'] is True:
self.scrape_amendments(bill, row['LegislationId'])
yield from self.scrape_votes(bill, row['LegislationId'], session)
yield bill