Skip to content
This repository was archived by the owner on Nov 5, 2023. It is now read-only.

Commit f050540

Browse files
Add in new method and deprecate old ones
1 parent ef361e2 commit f050540

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

pubproxpy/fetcher.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from datetime import datetime as dt
99
import json
1010
import os
11+
import sys
1112
from time import sleep
1213
from urllib.parse import urlencode
1314

@@ -178,12 +179,7 @@ def drain(self):
178179
"""
179180
return self.get_proxies(len(self._proxies))
180181

181-
def get_proxy(self):
182-
"""Attempts to get a single proxy matching the specified params
183-
"""
184-
return self.get_proxies(1)[0]
185-
186-
def get_proxies(self, amount):
182+
def get(self, amount=1):
187183
"""Attempts to get `amount` proxies matching the specified params
188184
"""
189185
# Remove any blacklisted proxies from the internal list
@@ -210,6 +206,25 @@ def get_proxies(self, amount):
210206

211207
return temp
212208

209+
def get_proxy(self):
210+
"""
211+
!DEPRECATED!
212+
Attempts to get a single proxy matching the specified params
213+
"""
214+
return self.get_proxies(1)[0]
215+
216+
def get_proxies(self, amount):
217+
"""
218+
!DEPRECATED!
219+
Attempts to get `amount` proxies matching the specified params
220+
"""
221+
print(
222+
"DEPRECATED: this method is deprecated in favor of `.get(...)` and"
223+
" will be removed in the next major version of the library (2.0)",
224+
file=sys.stderr,
225+
)
226+
return self.get(amount)
227+
213228
def _fetch(self):
214229
"""Attempts to get the proxies from pubproxy.com, will `sleep` to
215230
prevent getting rate-limited

0 commit comments

Comments
 (0)