Module: CoaOpScraper
- Defined in:
- lib/tames.rb,
lib/legacy.rb,
lib/coa_docket_no.rb,
lib/coa_op_scraper.rb
Defined Under Namespace
Modules: Legacy, Tames Classes: CoaDocketNo
Constant Summary collapse
- HISTORICAL_THROTTLE =
The Texas appellate websites are sometimes fragile. These sleep intervals should give ample time between requests.
10
- CURRENT_THROTTLE =
5
- TAMES_COAS =
A court’s placement in one of these two hashes tells you about the webpage format currently used by that court.
[ "01", "03", "04", "05", "06", "09", "11", "12", "14" ]
- LEGACY_COAS =
[ "02", "07", "08", "10", "13" ]
- @@check_weekends =
FALSE
Class Method Summary collapse
-
.parse_coa_opinion_list_at(coa, url) ⇒ Object
returns an array of URLs.
-
.scrape_one_opinion_list(coa, target_date) ⇒ Object
This is the easiest method to use here.
-
.urls_for_historical_range(coa, start_date, end_date) ⇒ Object
These methods would be useful to populate a queue of opinion lists to check later.
Class Method Details
.parse_coa_opinion_list_at(coa, url) ⇒ Object
returns an array of URLs
57 58 59 |
# File 'lib/coa_op_scraper.rb', line 57 def self.parse_coa_opinion_list_at(coa, url) self.scrape_one_opinion_list(coa, url) || [] end |
.scrape_one_opinion_list(coa, target_date) ⇒ Object
This is the easiest method to use here. Feed it a COA value (in the form “03”, for example) and the date for which you want the results (in the form of a Ruby date object).
28 29 30 31 32 33 34 35 |
# File 'lib/coa_op_scraper.rb', line 28 def self.scrape_one_opinion_list(coa,target_date) doc = self.retrieve_list_for_coa_for_date(coa,target_date) if CoaOpScraper::TAMES_COAS[coa] CoaOpScraper::Tames.parse_opinion_list(doc) elsif CoaOpScraper::LEGACY_COAS[coa] CoaOpScraper::Legacy.parse_opinion_list(doc) end end |
.urls_for_historical_range(coa, start_date, end_date) ⇒ Object
These methods would be useful to populate a queue of opinion lists to check later.
The #urls_for_historical_range method will, as expected, compute a list of the URLs that are appropriate (excluding weekends by default).
The #parse_coa_opinion_list_at method will take a coa number and a URL and return back a list of the results.
48 49 50 51 52 53 54 55 |
# File 'lib/coa_op_scraper.rb', line 48 def self.urls_for_historical_range(coa, start_date, end_date) result = [] (start_date .. end_date).each do |target_date| next unless @@check_weekends or target_date.weekday? result << self.url_for_coa_for_date(coa, target_date) end result end |