Skip to content

Instantly share code, notes, and snippets.

@cweiland
Forked from mkubenka/get_snds_data.py
Created June 1, 2019 07:58
Show Gist options
  • Save cweiland/9e0b0aba36ee112b43e0515a79a82f92 to your computer and use it in GitHub Desktop.
Save cweiland/9e0b0aba36ee112b43e0515a79a82f92 to your computer and use it in GitHub Desktop.
Download Outlook Smart Network Data Service Data for last 90 days
# 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