Repository: openstates/openstates-scrapers

Issue:
LA failing since at least 2018-03-23
LA has been failing since 2018-03-23

Based on automated runs it appears that LA has not run successfully in 2 days (2018-03-23).


```
  01:26:26 INFO pupa: save bill SB287 in 2018 as bill_47ec11ac-2f2c-11e8-b79e-0a58a9feac2a.json
01:26:26 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillInfo.aspx?i=233744
01:26:27 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233744&t=authors
01:26:28 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233744&t=digests
01:26:29 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233744&t=text
01:26:30 INFO pupa: save bill SB288 in 2018 as bill_4a4ef5b8-2f2c-11e8-b79e-0a58a9feac2a.json
01:26:30 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillInfo.aspx?i=233745
01:26:31 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233745&t=authors
01:26:32 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233745&t=digests
01:26:33 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233745&t=text
01:26:34 INFO pupa: save bill SB289 in 2018 as bill_4cb25f0c-2f2c-11e8-b79e-0a58a9feac2a.json
01:26:34 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillInfo.aspx?i=233786
01:26:35 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233786&t=authors
01:26:36 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233786&t=digests
01:26:37 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233786&t=text
01:26:38 INFO pupa: save bill SB290 in 2018 as bill_4f155f7e-2f2c-11e8-b79e-0a58a9feac2a.json
01:26:38 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillInfo.aspx?i=233787
01:26:39 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233787&t=authors
01:26:40 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233787&t=digests
01:26:41 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233787&t=text
01:26:42 INFO pupa: save bill SB291 in 2018 as bill_5178c3f0-2f2c-11e8-b79e-0a58a9feac2a.json
01:26:42 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillInfo.aspx?i=233788
01:26:43 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233788&t=authors
01:26:44 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233788&t=digests
01:26:45 INFO scrapelib: GET - http://www.legis.la.gov/Legis/BillDocs.aspx?i=233788&t=text
01:26:46 INFO scrapelib: GET - http://www.legis.la.gov/Legis/ViewDocument.aspx?d=1077749
loaded Open States pupa settings...
la (scrape, import)
  bills: {}
  committees: {}
  people: {}
Traceback (most recent call last):
  File "/opt/openstates/venv-pupa//bin/pupa", line 11, in <module>
    load_entry_point('pupa', 'console_scripts', 'pupa')()
  File "/opt/openstates/venv-pupa/src/pupa/pupa/cli/__main__.py", line 68, in main
    subcommands[args.subcommand].handle(args, other)
  File "/opt/openstates/venv-pupa/src/pupa/pupa/cli/commands/update.py", line 260, in handle
    return self.do_handle(args, other, juris)
  File "/opt/openstates/venv-pupa/src/pupa/pupa/cli/commands/update.py", line 305, in do_handle
    report['scrape'] = self.do_scrape(juris, args, scrapers)
  File "/opt/openstates/venv-pupa/src/pupa/pupa/cli/commands/update.py", line 173, in do_scrape
    report[scraper_name] = scraper.do_scrape(**scrape_args)
  File "/opt/openstates/venv-pupa/src/pupa/pupa/scrape/base.py", line 111, in do_scrape
    for obj in self.scrape(**kwargs) or []:
  File "/opt/openstates/openstates/openstates/la/bills.py", line 119, in scrape
    bill_abbreviation)
  File "/opt/openstates/openstates/openstates/la/bills.py", line 292, in scrape_bill_page
    url=amendment.attrib['href'],
  File "src/lxml/etree.pyx", line 2457, in lxml.etree._Attrib.__getitem__
KeyError: 'href'
```

Visit http://bobsled.openstates.org for more info.



Discussion:
Looking into it.

Resolving patch:
diff --git a/openstates/la/bills.py b/openstates/la/bills.py
--- a/openstates/la/bills.py
+++ b/openstates/la/bills.py
@@ -39,7 +39,8 @@ def pdf_to_lxml(self, filename, type='html'):
     def _get_bill_abbreviations(self, session_id):
         page = self.lxmlize('http://www.legis.la.gov/legis/BillSearch.aspx?'
                             'sid={}'.format(session_id))
-        select_options = page.xpath('//select[contains(@id, "InstTypes")]/option')
+        select_options = page.xpath(
+            '//select[contains(@id, "InstTypes")]/option')
 
         bill_abbreviations = {
             'upper': [],
@@ -288,9 +289,10 @@ def sbp(x): return self.scrape_bare_page(page.xpath(
                                   media_type="application/pdf")
 
         for amendment in amendments:
-            bill.add_version_link(note=amendment.text,
-                                  url=amendment.attrib['href'],
-                                  media_type="application/pdf")
+            if 'href' in amendment.attrib:
+                bill.add_version_link(note=amendment.text,
+                                      url=amendment.attrib['href'],
+                                      media_type="application/pdf")
 
         flags = {
             "prefiled": ["filing"],


Test patch: