Skip to content

Commit

Permalink
Merge cdc8f5a into 2a62bcb
Browse files Browse the repository at this point in the history
  • Loading branch information
LePetitTim committed Mar 21, 2019
2 parents 2a62bcb + cdc8f5a commit 2a5cc5e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mapentity/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import math
import os
import string
import time
from datetime import datetime
from mimetypes import types_map

Expand Down Expand Up @@ -153,7 +154,15 @@ def download_to_stream(url, stream, silent=False, headers=None):

content_error = 'Request on %s returned empty content' % url
assert len(source.content) > 0, content_error

except requests.exceptions.ConnectionError:
time.sleep(1)
headers['User-Agent'] = 'Mozilla/5.0 ' \
'(Macintosh; Intel Mac OS X 10_9_3) ' \
'AppleWebKit/537.36 (KHTML, like Gecko) ' \
'Chrome/35.0.1916.47 Safari/537.36'
source = requests.get(url, headers=headers)
status_error = 'Request on %s failed (status=%s)' % (url, source.status_code)
assert source.status_code == 200, status_error
except (AssertionError, requests.exceptions.RequestException) as e:
logger.exception(e)
logger.info('Headers sent: %s' % headers)
Expand Down

0 comments on commit 2a5cc5e

Please sign in to comment.