nick34992
2/15/2017 - 1:47 AM

urllib Python Module: ARIN PPML Archives by Year and Month

urllib Python Module: ARIN PPML Archives by Year and Month

#!/usr/bin/env python3
# python3 arin_ppml.py 2016 December | less

import sys, urllib.request

try:
    year_numbr = int(sys.argv[1])  # arg1
    month_name = str(sys.argv[2])  # arg2
except (IndexError, ValueError):
    print('Please enter year number and month name')
    sys.exit(2)

template = 'http://lists.arin.net/pipermail/arin-ppml/{}-{}.txt'
url = template.format(year_numbr, month_name)
ppml_raw = urllib.request.urlopen(url).read()
ppml = ppml_raw.decode('utf-8')
print(ppml)