From the Terminal command line
Get the current URL from Safari
osascript -e 'tell app "safari" to get the url of the current tab of window 1'
Get the active URL in Google Chrome
osascript -e 'tell app "google chrome" to get the url of the active tab of window 1'