Monday, September 14, 2015

Thermocline Adventure Update: Google Maps Gives You Everything You Need

Background here.

I made a list of cities along I-5 from San Ysidro, CA to Blaine, WA. It turns out that all I need to do is feed them into Google Maps like so:

https://www.google.com/maps/place/San+Ysidro,+CA

and then look for the div tag with the class "cards-entity-weather-and-time." From there, I can get everything I need. Check this out for Skagit City, WA:

<div jstcache="185" class="cards-entity-weather-and-time">
<a target="_blank" jstcache="186" href="/#q=Skagit City, WA 98273 weather" class="cards-entity-weather-icon" tabindex="0">
<img jstcache="187" src="//ssl.gstatic.com/onebox/weather/32/partly_cloudy.png">
</a>
<div jstcache="188" class="cards-entity-weather-contition-text" jsan="7.cards-entity-weather-contition-text">Mostly Cloudy · 49°F</div>
<div jstcache="189" class="cards-entity-time" jsan="7.cards-entity-time">6:16 AM</div>
</div>

The href in the first a tag gives me the text value of the city including the zip code* and the div with class "cards-entity-weather-contition-text" gives me the temperature. Put it in a cron job and have it harvest the data every couple of hours and I've got a database of temperatures along I5 as a function of time.

Since it's real-time and not predictive, we'd be chasing the thermocline instead of surfing it, but sometimes pursuit is more fun, no?

* - I only note this because I don't have the zip codes for my list of cities. This little trick with Google Maps will help me fill out my database in case I want to use a different source for information and I need the zips.

No comments: