Class: Scraper
- Inherits:
-
Object
- Object
- Scraper
- Defined in:
- lib/craigslister/scraper.rb
Overview
Houses all higher level scraping logic
Instance Method Summary collapse
-
#initialize(url, base_url) ⇒ Scraper
constructor
A new instance of Scraper.
- #links ⇒ Object
- #scrape ⇒ Object
Constructor Details
#initialize(url, base_url) ⇒ Scraper
Returns a new instance of Scraper.
3 4 5 6 |
# File 'lib/craigslister/scraper.rb', line 3 def initialize(url, base_url) @url = url @base_url = base_url end |
Instance Method Details
#links ⇒ Object
8 9 10 |
# File 'lib/craigslister/scraper.rb', line 8 def links header_link.map { |link| format_link(link['href']) } end |
#scrape ⇒ Object
12 13 14 |
# File 'lib/craigslister/scraper.rb', line 12 def scrape links.flat_map { |link| post_from(link) } end |