yes-man-today
commited on
Commit
•
a633346
1
Parent(s):
d664719
rate limit comments
Browse files
regulatory_comments_api.py
CHANGED
@@ -53,6 +53,10 @@ class RegulationsDataFetcher:
|
|
53 |
|
54 |
if response.status_code == 200:
|
55 |
return response.json()
|
|
|
|
|
|
|
|
|
56 |
else:
|
57 |
print(f'Failed to retrieve comments: {response.status_code}')
|
58 |
return None
|
@@ -68,6 +72,10 @@ class RegulationsDataFetcher:
|
|
68 |
docket_data['data']['attributes']['modifyDate'],
|
69 |
docket_data['data']['attributes']['docketType'],
|
70 |
docket_data['data']['attributes']['keywords'])
|
|
|
|
|
|
|
|
|
71 |
else:
|
72 |
print(f'Failed to retrieve docket info: {response.status_code}')
|
73 |
return None
|
@@ -271,7 +279,7 @@ class RegCommentsAPI(datasets.GeneratorBasedBuilder):
|
|
271 |
docket_data = fetcher.collect_data()
|
272 |
|
273 |
if docket_data is None:
|
274 |
-
print(f"
|
275 |
break
|
276 |
|
277 |
if len(docket_data["comments"]) != 0:
|
|
|
53 |
|
54 |
if response.status_code == 200:
|
55 |
return response.json()
|
56 |
+
elif response.status_code == 429:
|
57 |
+
print(f'API Rate Limit Reached')
|
58 |
+
return None
|
59 |
+
|
60 |
else:
|
61 |
print(f'Failed to retrieve comments: {response.status_code}')
|
62 |
return None
|
|
|
72 |
docket_data['data']['attributes']['modifyDate'],
|
73 |
docket_data['data']['attributes']['docketType'],
|
74 |
docket_data['data']['attributes']['keywords'])
|
75 |
+
elif response.status_code == 429:
|
76 |
+
print(f'API Rate Limit Reached')
|
77 |
+
return None
|
78 |
+
|
79 |
else:
|
80 |
print(f'Failed to retrieve docket info: {response.status_code}')
|
81 |
return None
|
|
|
279 |
docket_data = fetcher.collect_data()
|
280 |
|
281 |
if docket_data is None:
|
282 |
+
print(f"Error with API Retrieval.")
|
283 |
break
|
284 |
|
285 |
if len(docket_data["comments"]) != 0:
|