A while ago, I published the reworked script to get Office 365 URLs and IP address ranges. Microsoft has built a new fully rest full Webservice to get the same information via JSON instead of XML.
The only drawback of the new service: If you like to use it for a single produce, you need to filter after you have downloaded the information. The product sets are limited.
However, there are a lot of examples in the new script, these examples show you how, where, and what to filter.