Package: pubproxpy
PubproxpyAn easy to use Python wrapper forpubproxy's public proxy API.InstallationNOTE:The minimum python version for this library is 3.7, check withpython -Vorpython3 -Vif you're unsure about your current version.Install thepubproxpypackage using your standard Python package manager e.g.$pipinstallpubproxpyAs always you are recommended to install into a virtual environment.Keyless API LimitationsAPI Daily LimitsAt the time of writing this without an API key the pubproxy API limits users to 5 proxies per request and 50 requests per day. The maximum proxies per request is always used to minimize rate limiting along with getting the most proxies possible within the request limit meaning you should get 250 proxies per day without needing an API key.API Rate LimitingWithout an API key pubproxy limits users to one request per second so aProxyFetcherwill try to ensure that at most only one request per second is done without an API key. This is synchronized betweenProxyFetchers, but this is not thread safe so make sure allProxyFetchers are on one thread in one program if you have no API key. The rate limiting is quite severe, so upon being hit the API seems to deny requests for several minutes/hours.Quickstart ExamplefrompubproxpyimportLevel,Protocol,ProxyFetcher# ProxyFetcher for proxies that use the socks5 protocol, are located in# the US or Canada and support POST requestssocks_pf=ProxyFetcher(protocol=Protocol.SOCKS5,countries=["US","CA"],post=True)# ProxyFetcher for proxies that support https, are elite anonymity level,# and connected in 15 seconds or lesshttps_pf=ProxyFetcher(protocol=Protocol.HTTP,https=True,level=Level.ELITE,time_to_connect=15)# Get one socks proxy, followed by 10 https proxies# NOTE: even though there are multiple `ProxyFetcher`s the delays are#       coordinated between them to prevent rate limitingsocks_proxy=socks_pf.get()[0]# Get a single socks proxyhttps_proxies=https_pf.get(10)# Get a 10 https proxies# And then if you want to get any remaining proxies left over before you're# done you can!unused_proxies=socks_pf.drain()# Do something with the proxies, like spawn worker threads that use themDocumentationGetting proxies is handled by theProxyFetcherclass. There are several parameters you can pass on initialization to narrow down the proxies to a suitable type. From there you can just call.get(amount=1)to receive a list ofamountproxies where each proxy is in the form of"{ip}:{port}". There is an internal blacklist to ensure that the same proxy IP and port combo will not be used more than once by anyProxyFetcher, unlessexclude_usedisFalse.ProxyFetcherParametersSince the API doesn't check pretty much anything for correctness, we do our best in theProxyFetcherto ensure nothing is wrong. As far as I know the only thing that isn't checked is that thecountriesornot_countriesactually use the correct codes.ParameterTypeDescriptionexclude_usedbool[Default:True] If theProxyFetchershould prevent re-returning proxiesapi_keystrAPI key for a paid account, you can also set$PUBPROXY_API_KEYto pass your key, passing theapi_keyparameter will override the env-var if both are presentlevelpubproxpy.Level[Options:ANONYMOUS,ELITE] Proxy anonymity levelprotocolpubproxpy.Protocol[Options:HTTP,SOCKS4,SOCKS5] Desired communication protocolcountriesstrorlist<str>Locations of the proxy using theISO-3166 alpha-2country code,Incompatible withnot_countriesnot_countriesstrorlist<str>Blacklist locations of the proxy using theISO-3166 alpha-2country code,Incompatible withcountrieslast_checkedint[Bounds: 1-1000] Minutes since the proxy was checkedportintProxies using a specific porttime_to_connectint[Bounds: 1-60] How many seconds it took for the proxy to connectcookiesboolSupports requests with cookiesgoogleboolCan connect to GooglehttpsboolSupports HTTPS requestspostboolSupports POST requestsrefererboolSupports referer requestsuser_agentboolSupports forwarding user-agentsProxyFetcherMethodsKeeping it simple (stupid), so just.get(amount=1)and.drain().MethodReturns.get(amount=1)List ofamountproxies, where each proxy is astrin the form"{ip}:{port}".drain()Returns any proxies remaining in the current list, useful if you are no longer getting proxies and want to save any left overExceptionsAll the exceptions are defined inpubproxpy.errors.ExceptionDescriptionProxyErrorBase exception that all other pubproxpy errors inherit from, also raised when the API returns an unknown responseAPIKeyErrorError raised when the API gives an incorrect API Key responseRateLimitErrorError raised when the API gives a rate-limiting response (more than 1 request per second)DailyLimitErrorError raised when the API gives the daily request limit response