Repository: openstates/openstates-scrapers

Issue:
CT: Versions Information Missing for 2019 Session
When querying bill data I am not getting back information in several keys including and most importantly the versions key. An example response is included below.

```
"id"=>"",
   "type"=>["bill"],
   "state"=>"ct",
   "title"=>"AN ACT REQUIRING PUBLIC SERVICE COMPANIES TO PROVIDE NOTICE REGARDING MERGERS, ACQUISITIONS AND CHANGES TO THEIR CORPORATE STRUCTURE.",
   "votes"=>nil,
   "actions"=>[{"date"=>"2019-01-09 00:00:00", "type"=>["committee:referred"], "actor"=>"lower", "action"=>"REF. TO JOINT COMM. ON Energy and Technology", "related_entities"=>[]}],
   "all_ids"=>[""],
   "bill_id"=>"HB 5017",
   "chamber"=>"lower",
   "session"=>"2019",
   "sources"=>[{"url"=>"https://www.cga.ct.gov/asp/cgabillstatus/cgabillstatus.asp?selBillType=Bill&bill_num=HB5017&which_year=2019"}, {"url"=>"ftp://ftp.cga.ct.gov/pub/data/bill_info.csv"}],
   "summary"=>"",
   "sponsors"=>[{"name"=>"O'Neill, Arthur J.", "type"=>"primary", "leg_id"=>nil}],
   "subjects"=>[],
   "versions"=>[],
   "documents"=>[],
   "companions"=>[],
   "created_at"=>"2019-01-11 11:26:03",
   "updated_at"=>"2019-01-11 11:26:03",
   "action_dates"=>{"last"=>"2019-01-09 00:00:00", "first"=>"2019-01-09 00:00:00", "signed"=>nil, "passed_lower"=>nil, "passed_upper"=>nil},
   "alternate_titles"=>[],
   "scraped_subjects"=>["Merger and consolidation", "Notices", "Public utilities"],
   "alternate_bill_ids"=>[]},
```


Discussion:

Resolving patch:
diff --git a/openstates/ct/bills.py b/openstates/ct/bills.py
--- a/openstates/ct/bills.py
+++ b/openstates/ct/bills.py
@@ -30,8 +30,8 @@ def scrape(self, chamber=None, session=None):
         self.scrape_introducers('upper')
         self.scrape_introducers('lower')
         yield from self.scrape_bill_info(session, chambers)
-        for chamber in chambers:
-            self.scrape_versions(chamber, session)
+        # for chamber in chambers:
+        #     self.scrape_versions(chamber, session)
         self.scrape_bill_history()
 
         for bill in self.bills.values():
@@ -116,6 +116,13 @@ def scrape_bill_page(self, bill):
         for link in page.xpath("//a[contains(@href, '/BA/')]"):
             bill.add_document_link(link.text.strip(), link.attrib['href'])
 
+        for link in page.xpath("//a[contains(@href, '/pdf/') and contains(@href, '/TOB/')]"):
+            bill.add_version_link(
+                link.text.strip(),
+                link.attrib['href'],
+                media_type='application/pdf'
+            )
+
         for link in page.xpath("//a[contains(@href, 'VOTE')]"):
             # 2011 HJ 31 has a blank vote, others might too
             if link.attrib['href'].endswith('.htm') and link.text:
@@ -283,7 +290,7 @@ def scrape_bill_history(self):
 
     def scrape_versions(self, chamber, session):
         chamber_letter = {'upper': 's', 'lower': 'h'}[chamber]
-        versions_url = "ftp://ftp.cga.ct.gov/%s/tob/%s/" % (
+        versions_url = "ftp://ftp.cga.ct.gov/%s/tob/%s/pdf/" % (
             session, chamber_letter)
 
         page = self.get(versions_url).text
@@ -303,7 +310,7 @@ def scrape_versions(self, chamber, session):
                 continue
 
             url = versions_url + f.filename
-            bill.add_version_link(media_type='text/html',
+            bill.add_version_link(media_type='application/pdf',
                                   url=url,
                                   note=match.group(2))
 


Test patch: