This is probably what you are looking for (one of the code snippets does exactly what you want).
As for services/websites you can query to get the public ip address, here's a short list (you'll have to modify the example above to parse the response correctly):
http://checkip.dyndns.com
https://www.whatismypublicip.com/
http://freegeoip.net
https://who.is/
http://www.ipchicken.com/
http://www.whatsmyip.org/
https://api.ipify.org/
https://whatismyipaddress.com/
IMHO, the simplest is api.ipify.org. However, note that some of those service also answer geolocation info!
-----------------
Beno��t St-Jean
Yahoo! Messenger: bstjean
Twitter: @BenLeChialeux
Pinterest: benoitstjean
Instagram: Chef_Benito
IRC: lamneth
Blogue: endormitoire.wordpress.com
"A standpoint is an intellectual horizon of radius zero". (A. Einstein)