-
-
Save cweiland/9e0b0aba36ee112b43e0515a79a82f92 to your computer and use it in GitHub Desktop.
Download Outlook Smart Network Data Service Data for last 90 days
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Enable automated data access under https://postmaster.live.com/snds/auto.aspx | |
import datetime | |
import requests | |
import shutil | |
DATA_URL = 'https://postmaster.live.com/snds/data.aspx?key=xx' | |
for i in range(90): | |
date = datetime.datetime.now() + datetime.timedelta(-i) | |
date = date.strftime('%m%d%y') | |
print date | |
r = requests.get('%s&date=%s' % (DATA_URL, date), stream=True) | |
if r.status_code == 200: | |
with open('%s.csv' % date, 'wb') as f: | |
r.raw.decode_content = True | |
shutil.copyfileobj(r.raw, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment