Skip to content

Commit

Permalink
[feature]. add proxies. add ignore codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Hedgehogues committed Oct 23, 2020
1 parent db73ced commit 94168a1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import requests


proxies = {}


class DataExtractor:
def __init__(self, *, url, sc=200, ctags=2, itag=1, ignore_codes=None, rtimeout=10, retries=5):
"""
Expand All @@ -27,7 +30,7 @@ def __init__(self, *, url, sc=200, ctags=2, itag=1, ignore_codes=None, rtimeout=
self.sc = sc
self.ctags = ctags
self.itag = itag
self.ignore_codes = {} if ignore_codes is None else ignore_codes
self.ignore_codes = {404} if ignore_codes is None else ignore_codes
self.ltimeout = rtimeout
self.retries = retries

Expand All @@ -46,7 +49,7 @@ def __retry(self, *, url):
code = None
content = None
while i < self.retries:
resp = requests.get(url)
resp = requests.get(url, proxies=proxies)
code = resp.status_code
if resp.status_code in self.ignore_codes:
print(url + ' in ignore codes', flush=True)
Expand Down Expand Up @@ -82,7 +85,7 @@ def lb_data(_id):
return resp.json()


timeout = 10
timeout = 1
url = 'https://www.kaggle.com/c/lyft-motion-prediction-autonomous-vehicles'

path_to_data = f'data/{url.split("/")[-1]}'
Expand Down

0 comments on commit 94168a1

Please sign in to comment.