import requests
import os


#get the html from view-source:https://aqs.epa.gov/aqsweb/airdata/download_files.html#Particulates
url = 'https://aqs.epa.gov/aqsweb/airdata/download_files.html#Particulates'
r = requests.get(url)
#loop through the html and find any links that contain 'daily_SPEC_'
for line in r.text.split('\n'):
    if 'daily_SPEC_' in line:

        #get the link
        url1 = line.split('href="')[1].split('"')[0]
        url = 'https://aqs.epa.gov/aqsweb/airdata/' + url1
        #download the file
        r = requests.get(url)
        with open(url1, 'wb') as f:
            f.write(r.content)
            print('Downloaded', url1)
            #unzip the file
            os.system('unzip ' + url1)
            #remove the zip file
            os.system('rm ' + url1)
