Repository: openstates/openstates-scrapers

Issue:
TN-scrape failing since at least 2020-02-03
TN-scrape has failed 3 times since 2020-02-03

Logs:
```
23:39:11 INFO scrapelib: GET - http://wapp.capitol.tn.gov/apps/BillInfo/default.aspx?BillNumber=SB2177&GA=111
23:39:12 INFO pupa: save bill SB 2177 in 111 as bill_ac6fa122-4710-11ea-9bce-02e460667b0f.json
23:39:12 INFO scrapelib: GET - http://wapp.capitol.tn.gov/apps/indexes/BillIndex.aspx?StartNum=SB2201&EndNum=SB2201
23:39:13 INFO scrapelib: GET - http://wapp.capitol.tn.gov/apps/BillInfo/default.aspx?BillNumber=SB2201&GA=111
Traceback (most recent call last):
  File "/root/.cache/pypoetry/virtualenvs/**BACKUPS/PGUSER**-vRcYrsYN-py3.7/bin/pupa", line 11, in <module>
    load_entry_point('pupa==0.10.0', 'console_scripts', 'pupa')()
  File "/root/.cache/pypoetry/virtualenvs/**BACKUPS/PGUSER**-vRcYrsYN-py3.7/lib/python3.7/site-packages/pupa/cli/__main__.py", line 68, in main
    subcommands[args.subcommand].handle(args, other)
  File "/root/.cache/pypoetry/virtualenvs/**BACKUPS/PGUSER**-vRcYrsYN-py3.7/lib/python3.7/site-packages/pupa/cli/commands/update.py", line 278, in handle
    return self.do_handle(args, other, juris)
  File "/root/.cache/pypoetry/virtualenvs/**BACKUPS/PGUSER**-vRcYrsYN-py3.7/lib/python3.7/site-packages/pupa/cli/commands/update.py", line 327, in do_handle
    report['scrape'] = self.do_scrape(juris, args, scrapers)
  File "/root/.cache/pypoetry/virtualenvs/**BACKUPS/PGUSER**-vRcYrsYN-py3.7/lib/python3.7/site-packages/pupa/cli/commands/update.py", line 175, in do_scrape
    report[scraper_name] = scraper.do_scrape(**scrape_args)
  File "/root/.cache/pypoetry/virtualenvs/**BACKUPS/PGUSER**-vRcYrsYN-py3.7/lib/python3.7/site-packages/pupa/scrape/base.py", line 114, in do_scrape
    for iterobj in obj:
  File "/opt/**BACKUPS/PGUSER**/**BACKUPS/PGUSER**/**BACKUPS/PGUSER**/tn/bills.py", line 427, in scrape_bill
    cotable = page.xpath("//table[@id='gvCoActionHistory']")[0]
IndexError: list index out of range
```
        


Discussion:

Resolving patch:
diff --git a/openstates/tn/bills.py b/openstates/tn/bills.py
--- a/openstates/tn/bills.py
+++ b/openstates/tn/bills.py
@@ -355,7 +355,9 @@ def scrape_bill(self, session, bill_url):
             bill.add_identifier(secondary_bill_id)
 
         if page.xpath('//span[@id="lblCompNumber"]/a'):
-            companion_id = page.xpath('//span[@id="lblCompNumber"]/a')[0].text_content().strip()
+            companion_id = (
+                page.xpath('//span[@id="lblCompNumber"]/a')[0].text_content().strip()
+            )
             bill.add_related_bill(
                 identifier=companion_id,
                 legislative_session=session,
@@ -424,8 +426,9 @@ def scrape_bill(self, session, bill_url):
                 )
 
             # secondary actions
-            cotable = page.xpath("//table[@id='gvCoActionHistory']")[0]
-            actions_from_table(bill, cotable)
+            if page.xpath("//table[@id='gvCoActionHistory']"):
+                cotable = page.xpath("//table[@id='gvCoActionHistory']")[0]
+                actions_from_table(bill, cotable)
 
         # votes
         yield from self.scrape_vote_events(bill, page, bill_url)


Test patch: