Use pasted Booking.com search URL to pin scrape destination

The location_search_url column existed but was dead — the scraper always
rebuilt the URL from the free-text location name. Now the Location
Configuration form takes a "Booking.com search URL" field: paste the
address-bar URL from a real search and the scraper lifts ss/dest_id/
dest_type from it (the most reliable destination pin). Falls back to
dest_id, then plain name. Server also extracts dest_id from the URL for
the column and derives a display name from ss when none is typed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-05 22:00:28 +00:00
parent 9e5728efb1
commit 579a189cb8
5 changed files with 97 additions and 24 deletions

View file

@ -319,7 +319,8 @@ const StatusPanel: React.FC<{ status: ScraperStatus | undefined, isLoading: bool
const SettingsTab: React.FC = () => {
const queryClient = useQueryClient()
const [locationName, setLocationName] = useState('')
const [pages, setPages] = useState(2)
const [searchUrl, setSearchUrl] = useState('')
const [pages, setPages] = useState(1)
const [adults, setAdults] = useState(2)
const [scrapeFrom, setScrapeFrom] = useState(() => fmtDate(new Date()))
const [scrapeTo, setScrapeTo] = useState(() => {
@ -359,6 +360,7 @@ const SettingsTab: React.FC = () => {
mutationFn: async () => {
return (await api.post('/competitors/config/location', {
location_name: locationName,
location_search_url: searchUrl || undefined,
pages_to_scrape: pages,
adults: adults,
})).data
@ -366,6 +368,7 @@ const SettingsTab: React.FC = () => {
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['scraper-status'] })
setLocationName('')
setSearchUrl('')
},
})
@ -416,6 +419,23 @@ const SettingsTab: React.FC = () => {
style={inputStyle}
/>
</div>
</div>
<div style={{ marginTop: '12px' }}>
<label style={inputLabelStyle}>Booking.com search URL (recommended)</label>
<input
type="text"
value={searchUrl}
onChange={e => setSearchUrl(e.target.value)}
placeholder="https://www.booking.com/searchresults.html?ss=…&dest_id=…"
style={inputStyle}
/>
<p style={{ fontSize: '12px', color: 'var(--text-mid)', margin: '6px 0 0' }}>
Search your area on booking.com and paste the address-bar URL here. It pins the
exact destination (a plain name can resolve to the wrong place). Dates and paging
are set automatically only the destination is read from the URL.
</p>
</div>
<div style={{ ...styles.formRow, marginTop: '12px' }}>
<div style={styles.formGroupSmall}>
<label style={inputLabelStyle}>Pages</label>
<input
@ -441,10 +461,10 @@ const SettingsTab: React.FC = () => {
</div>
<button
onClick={() => setLocationMutation.mutate()}
disabled={!locationName || setLocationMutation.isPending}
disabled={(!locationName && !searchUrl) || setLocationMutation.isPending}
style={mergeStyles(
buttonStyle('primary'),
{ marginTop: '16px', opacity: !locationName ? 0.5 : 1 }
{ marginTop: '16px', opacity: (!locationName && !searchUrl) ? 0.5 : 1 }
)}
>
{setLocationMutation.isPending ? 'Saving...' : 'Set Location'}