I mashed this up using some of the original code. It doesn't have the latest/best matching for AM/PM, but it does know how to find the correct strings:

Code:
#!/bin/bash

userAgent="Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"
googleQueryUrl="http://www.google.com/search?q="

## Sunrise:
googleQueryResult=$( curl -L -A "$userAgent" -s "${googleQueryUrl}sunrise" )
echo "$googleQueryResult" | sed -n -e 's/.*Sunrise..span.*\([01]*[0-9]:[0-5][0-9]\).\([aApP][.]*[mM]\).*/\1 \2/p' | sed -e 's/[aA][.][mM]/am/'

## Sunset:
googleQueryResult=$( curl -L -A "$userAgent" -s "${googleQueryUrl}sunset" )
echo "$googleQueryResult" | sed -n -e 's/.*Sunset..span.*\([01]*[0-9]:[0-5][0-9]\).\([aApP][.]*[mM]\).*/\1 \2/p' | sed -e 's/[pP][.][mM]/pm/'