import requests
from datetime import datetime, timedelta
# Get the date of the most recent CVE database
now = datetime.now()
# Download the CVE database from the NVD website
url = 'https://nvd.nist.gov/feeds/json/cve/1.1/nvdcve-1.1-{}.json.zip'.format(now.strftime('%Y'))
r = requests.get(url)
# Save the file
with open('nvdcve-1.1.zip', 'wb') as f:
f.write(r.content)
# Set up a timedelta object of 1 day
one_day = timedelta(days=1)
# Schedule the program to run every 24 hours
while True:
now = now + one_day
url = 'https://nvd.nist.gov/feeds/json/cve/1.1/nvdcve-1.1-{}.json.zip'.format(now.strftime('%Y'))
r = requests.get(url)
with open('nvdcve-1.1.zip', 'wb') as f:
f.write(r.content)
time.sleep(86400)