import subprocess # Open input and output files with open('urls.txt', 'r') as infile, open('report.txt', 'w') as outfile: # Process each URL for url in infile: url = url.strip() # Run pa11y command and capture output output = subprocess.check_output(f'npx pa11y {url}', shell=True, text=True) # Write URL and output to file outfile.write(f"------\nFILE: {url}\n\n{output}\n")