Class: PaBillreader::Scraper
- Inherits:
-
Object
- Object
- PaBillreader::Scraper
- Defined in:
- lib/pa_billreader/scraper.rb
Constant Summary collapse
- @@count =
0
Instance Attribute Summary collapse
-
#bills ⇒ Object
Returns the value of attribute bills.
Class Method Summary collapse
Instance Attribute Details
#bills ⇒ Object
Returns the value of attribute bills.
3 4 5 |
# File 'lib/pa_billreader/scraper.rb', line 3 def bills @bills end |
Class Method Details
.scrape_bill_detail(branch, bill) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pa_billreader/scraper.rb', line 20 def self.scrape_bill_detail(branch, bill) doc = Nokogiri::HTML(open("http://www.legis.state.pa.us/cfdocs/billinfo/billinfo.cfm?syear=2017&sind=0&body=#{branch}&type=B&bn=#{bill}")) bill_details = {} bill_details[:short_title] = doc.css("div.BillInfo-ShortTitle div.BillInfo-Section-Data").text.strip bill_details[:prime_sponsor] = doc.css("div.BillInfo-PrimeSponsor div.BillInfo-Section-Data").text.strip bill_details[:last_action] = doc.css("div.BillInfo-LastAction div.BillInfo-Section-Data").text.strip bill_details[:memo_url] = doc.css("div.BillInfo-CosponMemo div.BillInfo-Section-Data a").attr('href').value if doc.at_css("div.BillInfo-CosponMemo div.BillInfo-Section-Data a") bill_details[:full_text_url] = "http://www.legis.state.pa.us#{doc.css("table.DataTable.BillInfo-PNTable td[valign='middle'] a").attr('href').value}" if doc.at_css("table.DataTable.BillInfo-PNTable td[valign='middle'] a") bill_details end |
.scrape_bill_nums(branch) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/pa_billreader/scraper.rb', line 7 def self.scrape_bill_nums(branch) doc = Nokogiri::HTML(open("http://www.legis.state.pa.us/cfdocs/legis/bi/BillIndx.cfm?sYear=2017&sIndex=0&bod=#{branch}")) @bills = [] doc.css("table.DataTable")[0].css("td a").each { |id| @bills << {number: id.text, branch: branch} } PaBillreader::Bill.create_from_array(@bills) end |