Skip to content

Commit

Permalink
Fix problem with sites that blocks bots
Browse files Browse the repository at this point in the history
  • Loading branch information
rgaiacs committed Oct 19, 2018
1 parent db55e03 commit 4dceb44
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lowfat/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def online_document(url):
except HTTPError as exception:
if exception.code == 410:
raise ValidationError("Online document was removed.") # This is the code returned by Google Drive
elif exception.code == 403:
req = request.Request(url, headers={'User-Agent' : "lowFAT"})
online_resource = request.urlopen(req)
else:
raise ValidationError("Error! HTTP status code is {}.".format(exception.code))

# Need to test if website didn't redirect the request to another resource.
if url != online_resource.geturl() or online_resource.getcode() != 200:
Expand Down

0 comments on commit 4dceb44

Please sign in to comment.