Class: BandcampDiscover::Scrapers::Label
- Defined in:
- lib/bandcamp-discover/scrapers/label.rb
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from BandcampDiscover::Scrapers::Base
Instance Method Details
#scrape(force: false) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/bandcamp-discover/scrapers/label.rb', line 8 def scrape(force: false) super do |page| puts "starting to scrape #{@url}" page.goto(@url) bio_container = page.wait_for_selector("#bio-container") bio_text = bio_container.query_selector("#bio-text") band_name_location_container = page.wait_for_selector("#band-name-location") name = band_name_location_container.query_selector(".title").inner_text location = band_name_location_container.query_selector(".location").inner_text if force || Analyzer.new(bio_text&.inner_html).label? return Sync do albums, = Scrapers::Music.new(url: "#{@url}/music", browser: @browser, max_tasks: @max_tasks).scrape puts "done scraping #{@url}" { url: @url, name: name, location: location, bio: bio_text.inner_text, tags_with_weights: &.compact, albums: albums } end else puts "not a label: #{@url}" nil end end end |