Class: Retailer::Extractors::Lowes
- Inherits:
-
Base
- Object
- Base
- Retailer::Extractors::Lowes
- Defined in:
- app/services/retailer/extractors/lowes.rb
Overview
Lowe's data extractor (USA and Canada).
Uses JSON-LD structured data and specific selectors.
Supports URL discovery from search results.
URL formats:
USA: https://www.lowes.com/pd/product-slug/product-id
Canada: https://www.lowes.ca/product/product-slug-product-id
Class Method Summary collapse
-
.build_payload(url:, geo_location: nil) ⇒ Hash
Build Oxylabs payload for Lowe's product scraping Uses 'universal' source with JS rendering.
Instance Method Summary collapse
Class Method Details
.build_payload(url:, geo_location: nil) ⇒ Hash
Build Oxylabs payload for Lowe's product scraping
Uses 'universal' source with JS rendering.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/services/retailer/extractors/lowes.rb', line 18 def self.build_payload(url:, geo_location: nil) payload = { source: 'universal', url: url, render: 'html', context: [ { key: 'follow_redirects', value: true } ] } payload[:geo_location] = geo_location if geo_location.present? payload end |
Instance Method Details
#catalog_base_url ⇒ Object (protected)
49 50 51 |
# File 'app/services/retailer/extractors/lowes.rb', line 49 def catalog_base_url catalog.id == LOWES_CANADA ? 'https://www.lowes.ca' : 'https://www.lowes.com' end |
#extract(check, content) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/services/retailer/extractors/lowes.rb', line 31 def extract(check, content) return unless valid_html?(content) check.scraper_source = source_name check.currency = catalog.id == LOWES_CANADA ? 'CAD' : 'USD' doc = parse_html(content) # Determine if this is a search results page or product page if search_results_page?(content) extract_from_search_page(check, doc) else extract_from_product_page(check, doc, content) end end |