Class: BandcampDiscover::Scrapers::Base
- Inherits:
-
Object
- Object
- BandcampDiscover::Scrapers::Base
- Defined in:
- lib/bandcamp-discover/scrapers/base.rb
Instance Method Summary collapse
-
#initialize(url:, browser:, max_tasks: 2) ⇒ Base
constructor
A new instance of Base.
- #scrape(force: false) ⇒ Object
Constructor Details
#initialize(url:, browser:, max_tasks: 2) ⇒ Base
Returns a new instance of Base.
10 11 12 13 14 15 |
# File 'lib/bandcamp-discover/scrapers/base.rb', line 10 def initialize(url:, browser:, max_tasks: 2) @url = url @browser = browser @page = browser.new_page @max_tasks = max_tasks end |
Instance Method Details
#scrape(force: false) ⇒ Object
17 18 19 20 21 |
# File 'lib/bandcamp-discover/scrapers/base.rb', line 17 def scrape(force: false) yield @page if block_given? rescue Playwright::TimeoutError => e raise ScrapeError, "Timed out waiting for an element on #{@url}: #{e.}" end |