Repository: openstates/openstates-scrapers

Issue:
KY failing since at least 2019-02-02
KY has been failing since 2019-02-02

Based on automated runs it appears that KY has not run successfully in 2 days (2019-02-02).


```
  loaded Open States pupa settings...
ky (scrape, import)
  bills: {}
06:01:03 CRITICAL pupa: no sessions from Kentucky.get_session_list()
```

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



Discussion:

Resolving patch:
diff --git a/openstates/ky/__init__.py b/openstates/ky/__init__.py
--- a/openstates/ky/__init__.py
+++ b/openstates/ky/__init__.py
@@ -29,7 +29,7 @@ class Kentucky(Jurisdiction):
             "start_date": "2011-01-04"
         },
         {
-            "_scraped_name": "2011 Extraordinary Session",
+            "_scraped_name": "2011 Special Session",
             "classification": "special",
             "end_date": "2011-04-06",
             "identifier": "2011SS",
@@ -45,7 +45,7 @@ class Kentucky(Jurisdiction):
             "start_date": "2012-01-03"
         },
         {
-            "_scraped_name": "2012 Extraordinary Session",
+            "_scraped_name": "2012 Special Session",
             "classification": "special",
             "end_date": "2012-04-20",
             "identifier": "2012SS",
@@ -61,7 +61,7 @@ class Kentucky(Jurisdiction):
             "start_date": "2013-01-08"
         },
         {
-            "_scraped_name": "2013 Extraordinary Session",
+            "_scraped_name": "2013 Special Session",
             "classification": "special",
             "end_date": "2013-08-19",
             "identifier": "2013SS",
@@ -124,7 +124,33 @@ class Kentucky(Jurisdiction):
             "start_date": "2019-01-08"
         },
     ]
-    ignored_scraped_sessions = []
+    ignored_scraped_sessions = [
+        '2019 Regular Session Prefiled Bills',
+        '2011 Special Session',
+        '2011 Regular Session',
+        '2010 Special Session',
+        '2010 Regular Session',
+        '2009 Special Session',
+        '2009 Regular Session',
+        '2008 Special Session',
+        '2008 Regular Session',
+        '2007 2nd Special Session',
+        '2007 Special Session',
+        '2007 Regular Session',
+        '2006 Special Session',
+        '2006 Regular Session',
+        '2005 Regular Session',
+        '2004 Special Session',
+        '2004 Regular Session',
+        '2003 Regular Session',
+        '2002 Special Session',
+        '2002 Regular Session',
+        '2001 Regular Session',
+        '2000 Regular Session',
+        '1998 Regular Session',
+        '1997 Special Session (Sept)',
+        '1997 Special Session (May)',
+    ]
 
     def get_organizations(self):
         legislature_name = "Kentucky General Assembly"
@@ -142,11 +168,12 @@ def get_organizations(self):
 
     def get_session_list(self):
         sessions = url_xpath(
-            'http://www.lrc.ky.gov/legislation.htm',
-            '//a[contains(@href, "record.htm")]/text()[normalize-space()]')
+            'https://apps.legislature.ky.gov/record/pastses.html',
+            '//td/div/a/text()')
 
         for index, session in enumerate(sessions):
             # Remove escaped whitespace characters.
-            sessions[index] = re.sub(r'[\r\n\t]+', '', session)
+            sessions[index] = re.sub(r'\s\s+', ' ', session)
+            sessions[index] = sessions[index].strip()
 
         return sessions
diff --git a/openstates/ky/bills.py b/openstates/ky/bills.py
--- a/openstates/ky/bills.py
+++ b/openstates/ky/bills.py
@@ -15,7 +15,7 @@ def chamber_abbr(chamber):
 
 
 def session_url(session):
-    return "http://www.lrc.ky.gov/record/%s/" % session[2:]
+    return "https://apps.legislature.ky.gov/record/%s/" % session[2:]
 
 
 class KYBillScraper(Scraper, LXMLMixin):
@@ -182,7 +182,7 @@ def parse_bill(self, chamber, session, bill_id, url):
             bill.add_document_link(
                 "Fiscal Note", source_url, media_type=mimetype)
 
-        for link in page.xpath("//a[contains(@href, 'legislator/')]"):
+        for link in page.xpath("//td/span/a[contains(@href, 'Legislator-Profile')]"):
             bill.add_sponsorship(link.text.strip(), classification='primary',
                                  entity_type='person', primary=True)
 


Test patch: