Purpose
Warm a forecast.weather.gov location profile and return its current page identity, current conditions, and available forecast-period summaries without replaying homepage navigation.
When to Use
Use when a caller needs to preload or inspect a weather.gov forecast profile for a city or point. Prefer the direct MapClick URL when the caller supplies the weather-office code and location parameters.
Workflow
- Build the direct forecast URL:
https://forecast.weather.gov/MapClick.php?CityName={city}&state={state}&site={office-code}Add&textField1={latitude}&textField2={longitude}&e=0when exact point coordinates are available. - In one browser-agent call, navigate to that URL with
waitUntil: "domcontentloaded", allow the forecast content to settle, and run this evaluator on the loaded page:(() => { const text = (selector) => { const el = document.querySelector(selector); return el ? el.textContent.replace(/\\s+/g, " ").trim() : null; }; const periods = [ ...document.querySelectorAll( "#seven-day-forecast .tombstone, #seven-day-forecast .forecast-tombstone", ), ] .map((el) => ({ name: el .querySelector(".period-name") ?.textContent.replace(/\\s+/g, " ") .trim() || null, description: el .querySelector(".short-desc") ?.textContent.replace(/\\s+/g, " ") .trim() || null, temperature: el.querySelector(".temp")?.textContent.replace(/\\s+/g, " ").trim() || null, imageAlt: el.querySelector("img")?.getAttribute("alt") || null, })) .filter((p) => p.name || p.description || p.temperature); return { url: location.href, title: document.title, location: text("#seven-day-forecast h2, #location h1, .panel-title"), currentConditions: text("#current_conditions-summary"), currentDetails: text("#current_conditions_detail"), forecastPeriods: periods, }; })();
Site-Specific Gotchas
- The forecast page is directly reachable at
/MapClick.php; a homepage visit and search-box interaction are unnecessary. site={office-code}is a weather-office identifier, not a freely guessed city slug. Preserve an office code supplied by the caller or obtained from weather.gov location lookup.textField1is latitude andtextField2is longitude. Include them for an exact point forecast;e=0is the observed point-selection flag.- Forecast content is rendered in the standard
#current_conditions-summary,#current_conditions_detail, and#seven-day-forecastregions. Some pages may omit one region, so the evaluator returnsnullor an empty list rather than failing.
Expected Output
An object containing the final URL, document title, location heading when present, current-condition text, current-detail text, and structured forecast-period summaries.