jrunscript -e "`curl -o - -s http://wpad/wpad.dat` function isPlainHostName(hostname) { return hostname.indexOf('.')==-1;}; var proxyList = FindProxyForURL('http://github.com','github.com'); var firstProxy = proxyList.split(';')[0].trim(); print('DIRECT'.equals(firstProxy) ? '' : 'http://' + firstProxy.split(' ')[1]);"
Depending on your local environment you might have to implement one or more functions from the list that your wpad.dat expects, in our case I needed to implement isPlainHost.
The last part of the script just picks the first proxy name, as the function returns a list of PROXY is suggested order. The raw output looks like this:
PROXY london.example.com:80; PROXY sf.example.com:80; DIRECT;
So we just pick the first one with http as the prefix, as some tools such as docker are fussy about this, or returns an empty string if DIRECT is recommended.
http://london.example.com:80