From c21350a15b548afc11891f34b8c26e819e22653c Mon Sep 17 00:00:00 2001 From: Martin Cech Date: Sun, 4 Feb 2018 23:55:37 -0500 Subject: [PATCH] use the altest version of PSL database --- requirements.txt | 1 + verify.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index 3ad8980..1c5776a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ publicsuffixlist +requests diff --git a/verify.py b/verify.py index fd6d40c..de16b75 100644 --- a/verify.py +++ b/verify.py @@ -7,11 +7,14 @@ import io import sys from publicsuffixlist import PublicSuffixList +from requests import get def main(arguments): - psl = PublicSuffixList() suffix_detected = False - + psl = None + download_suffixes() + with open("public_suffix_list.dat", "r") as latest: + psl = PublicSuffixList(latest) with io.open('disposable_email_blacklist.conf', 'r') as deb: for i, line in enumerate(deb): current_line = line.strip() @@ -23,6 +26,12 @@ def main(arguments): print ('At least one valid public suffix found in the blacklist, please remove it. See https://publicsuffix.org for details on why this shouldn\'t be blacklisted.') sys.exit(1) +def download_suffixes(): + with open('public_suffix_list.dat', "wb") as file: + response = get('https://publicsuffix.org/list/public_suffix_list.dat') + file.write(response.content) + + if __name__ == "__main__": main(sys.argv)