mirror of
https://github.com/public-apis/public-apis.git
synced 2025-05-29 17:06:23 +02:00
Fix links validation script (#1426)
This commit is contained in:
parent
aa621059a7
commit
dc903e6dd2
2 changed files with 6 additions and 4 deletions
|
@ -1,4 +1,6 @@
|
||||||
# Public APIs [](https://github.com/public-apis/public-apis/actions?query=workflow%3A%22Run+tests%22)
|
# Public APIs [](https://github.com/public-apis/public-apis/actions?query=workflow%3A%22Run+tests%22) [](https://github.com/public-apis/public-apis/actions?query=workflow%3A%22Validate+links%22)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
A collective list of free APIs for use in software and web development.
|
A collective list of free APIs for use in software and web development.
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,9 @@ def validate_links(links):
|
||||||
print('Validating {} links...'.format(len(links)))
|
print('Validating {} links...'.format(len(links)))
|
||||||
errors = []
|
errors = []
|
||||||
for link in links:
|
for link in links:
|
||||||
h = httplib2.Http(disable_ssl_certificate_validation=True, timeout=10)
|
h = httplib2.Http(disable_ssl_certificate_validation=True, timeout=25)
|
||||||
try:
|
try:
|
||||||
resp = h.request(link)
|
resp = h.request(link, headers={'user-agent': 'Mozilla/5.0'})
|
||||||
code = int(resp[0]['status'])
|
code = int(resp[0]['status'])
|
||||||
# check if status code is a client or server error
|
# check if status code is a client or server error
|
||||||
if code >= 404:
|
if code >= 404:
|
||||||
|
@ -37,7 +37,7 @@ def validate_links(links):
|
||||||
# Ignore some exceptions which are not actually errors.
|
# Ignore some exceptions which are not actually errors.
|
||||||
# The list below should be extended with other exceptions in the future if needed
|
# The list below should be extended with other exceptions in the future if needed
|
||||||
if ((-1 != str(e).find("Content purported to be compressed with gzip but failed to decompress.")) and
|
if ((-1 != str(e).find("Content purported to be compressed with gzip but failed to decompress.")) and
|
||||||
(-1 != str(e).find("[SSL: CERTIFICATE_VERIFY_FAIL)ED] certificate verify failed (_ssl.c:852)"))) :
|
(-1 != str(e).find("[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)"))) :
|
||||||
errors.append("ERR: {} : {}".format(e, link))
|
errors.append("ERR: {} : {}".format(e, link))
|
||||||
return errors
|
return errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue