I'm trying to create a basic link checker in python.
When using the following code:
def get_link_response_code(link_to_check):
resp = requests.get(link_to_check)
return resp.status_code
I'm always getting the right response code but it takes considerable ammount of time.
But when using this code: (requests.get replaced with requests.head)
def get_link_response_code(link_to_check):
resp = requests.head(link_to_check)
return resp.status_code
It usually works, and very fast, but sometimes return HTTP 405 (for a link which is not really broken).
Why am I getting 405 (wrong method) errors? what can I do to quickly check for broken links? Thanks.