import serial
import webbrowser
sp = serial.Serial("COM4", 9600, timeout=2)
sp.flush()
while(1):
response = sp.read(1)
if response == b'0':
print("Got OK Byte. Waiting for button press.")
elif response == b'a':
print("%s received." % response)
webbrowser.open("http://www.jma.go.jp/jp/amedas_h/today-46106.html?areaCode=000&groupCode=32")
elif response == b's':
print("%s received." % response)
webbrowser.open("http://www.jma.go.jp/jp/amedas_h/today-46141.html?areaCode=000&groupCode=32")
else:
print("Got nothing. Still waiting.")