Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes every weekday Monday through Friday.
This page was generated by The HPR Robot at

hpr2919 :: hosting software in HPR show notes

boats are awesome, but might lead to hosting software in the HPR show notes

<< First, < Previous, , Latest >>

Hosted by Jezra on 2019-10-10 is flagged as Clean and is released under a CC-BY-SA license.
canoe, ptython, api, weather. (Be the first).
The show is available on the Internet Archive at:

Listen in ogg, spx, or mp3 format. Play now:

Duration: 00:10:26

Programming 101.

A series focusing on concepts and the basics of programming

#!/usr/bin/env python
import urllib.request
import json
import re
import subprocess

# see

#where are we? GPS coordinates
lat = 39.275235
lon = -120.9199507
#what is the user agent string?
agent = "Jezra's fun lil script"
#minimum wind speed in mph?
min_speed = 9

def get_api_data(endpoint):
  #prepare the connection with custom headers
  request = urllib.request.Request(endpoint, headers={"User-Agent":agent})
  #create a handler for the request
  handler = urllib.request.urlopen(request)
  #get the text
  text =
  #parse the json text to a python object
  obj = json.loads(text)
  return obj

def wind_is_good(s):
  #use regex to find the matches
  matches = re.findall("[0-9]+",s)
  for match in matches:
    #convert string to int
    m = int(match)
    #is the speed good?
      return True
  #if we get here, there is no match :(
  return False

start_url = "{0},{1}".format(lat,lon)
#get the json response from the start_url as a python object
obj = get_api_data(start_url)

#get the forecast url from the returned data
forecast_url = obj['properties']['forecast']

# process the forecast url
forecast = get_api_data(forecast_url)

#loop through the forcast periods
for period in forecast['properties']['periods']:
  #put name and windspeed into easier to handle variable names
  name= period['name']
  wind = period['windSpeed']
  print (name, wind)
  #check the wind speed
  if wind_is_good(wind):["textjezra","{0}: {1}".format(name,wind)])


Subscribe to the comments RSS feed.

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Anti Spam Question: What does the letter P in HPR stand for?
Are you a spammer?
What is the HOST_ID for the host of this show?
What does HPR mean to you?