Use text-search approach for rate conditions (breakfast/cancel/payment)
Original scrapy approach: extract <li> condition lines from each rate plan row and text-search for known keywords. No match = null (unknown), not assumed false. Adds breakfast_text, cancel_text, payment_text columns to booking_com_rates. Booleans now nullable (null = not mentioned, true/false = explicit signal). JS extraction searches all <li> items in the row (falls back to newline-split innerText if none). Breakfast: 'breakfast' keyword. Cancel: 'free cancellation', 'non-refundable', 'total cost to cancel', 'fully chargeable'. Payment: 'no prepayment', 'pay at the property', 'pay online'. data-fltrs used as fallback. API snapshot endpoint now returns breakfast/cancel/payment text strings. Old boolean-only rows degrade gracefully to derived labels. Modal plan rows replace the fixed meal|cancel|price column layout with a single stacked conditions cell: 0-3 lines depending on what the page actually shows. Breakfast green when 'included', cancel green when 'Free cancellation…'. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
69ecf1012e
commit
38b0c36923
6 changed files with 132 additions and 46 deletions
|
|
@ -133,6 +133,16 @@ ALTER TABLE booking_com_hotels ALTER COLUMN booking_com_id TYPE VARCHAR(255);
|
|||
ALTER TABLE booking_com_rates ADD COLUMN IF NOT EXISTS rate_plan_id TEXT;
|
||||
ALTER TABLE booking_com_rates ADD COLUMN IF NOT EXISTS max_persons INTEGER;
|
||||
|
||||
-- Raw condition text from the page (text search approach — null = not mentioned, not "no")
|
||||
ALTER TABLE booking_com_rates ADD COLUMN IF NOT EXISTS breakfast_text TEXT;
|
||||
ALTER TABLE booking_com_rates ADD COLUMN IF NOT EXISTS cancel_text TEXT;
|
||||
ALTER TABLE booking_com_rates ADD COLUMN IF NOT EXISTS payment_text TEXT;
|
||||
|
||||
-- Make condition booleans nullable (null = unknown, not assumed false)
|
||||
ALTER TABLE booking_com_rates ALTER COLUMN breakfast_included SET DEFAULT NULL;
|
||||
ALTER TABLE booking_com_rates ALTER COLUMN free_cancellation SET DEFAULT NULL;
|
||||
ALTER TABLE booking_com_rates ALTER COLUMN no_prepayment SET DEFAULT NULL;
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_booking_com_rates_hotel_date ON booking_com_rates(hotel_id, rate_date);
|
||||
CREATE INDEX IF NOT EXISTS idx_booking_com_rates_date ON booking_com_rates(rate_date);
|
||||
CREATE INDEX IF NOT EXISTS idx_booking_com_rates_scraped ON booking_com_rates(scraped_at DESC);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue