Skip to content
Snippets Groups Projects
Commit c1607441 authored by Janik Besendorf's avatar Janik Besendorf
Browse files

fixes ConnectionResetError in cc-scraper and adds error handling

parent b5ca4759
No related branches found
No related tags found
No related merge requests found
......@@ -32,14 +32,26 @@ with open ('filtered.csv', 'r') as filtered:
sys.exit(1)
csv_dict = csv.DictReader(filtered)
for row in csv_dict:
if row['Certification Report URL'] != '':
urllib.request.urlretrieve(row['Certification Report URL'].replace(' ','%20'),(row['Certification Report URL'].split('/')[-1]))
if row['Security Target URL'] != '':
urllib.request.urlretrieve(row['Security Target URL'].replace(' ','%20'),(row['Security Target URL'].split('/')[-1]))
if row['Maintenance Report'] != '':
urllib.request.urlretrieve(row['Maintenance Report'].replace(' ','%20'),(row['Maintenance Report'].split('/')[-1]))
if row['Maintenance ST'] != '':
urllib.request.urlretrieve(row['Maintenance ST'].replace(' ','%20'),(row['Maintenance ST'].split('/')[-1]))
if row['Certification Report URL'] != '':
try:
urllib.request.urlretrieve(row['Certification Report URL'].replace(' ','%20').replace(':443',''),(row['Certification Report URL'].split('/')[-1]))
except ConnectionResetError:
print('Connection reset by server. Continuing')
if row['Security Target URL'] != '':
try:
urllib.request.urlretrieve(row['Security Target URL'].replace(' ','%20').replace(':443',''),(row['Security Target URL'].split('/')[-1]))
except ConnectionResetError:
print('Connection reset by server. Continuing')
if row['Maintenance Report'] != '':
try:
urllib.request.urlretrieve(row['Maintenance Report'].replace(' ','%20').replace(':443',''),(row['Maintenance Report'].split('/')[-1]))
except ConnectionResetError:
print('Connection reset by server. Continuing')
if row['Maintenance ST'] != '':
try:
urllib.request.urlretrieve(row['Maintenance ST'].replace(' ','%20').replace(':443',''),(row['Maintenance ST'].split('/')[-1]))
except ConnectionResetError:
print('Connection reset by server. Continuing')
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment