Rotating Proxy
v0.1.6
用于有效管理和利用旋转代理的Python软件包。该模块提供了一种简单有效的方法来处理多个代理,自动在它们之间切换以增强Web刮擦或任何需要匿名的HTTP请求。
您可以使用PIP安装软件包:
pip install rotating-proxy from rotating_proxy import ProxyPool , ProxySession
class Project :
def __init__ ( self ):
# Initialize the proxy pool with a list of proxies.
# Replace "127.0.0.1:80" with your own proxies in the format:
# ["http://proxy1","http://proxy2",..."http://proxyN"]
self . proxy_pool = ProxyPool ([ "http://127.0.0.1:80" ])
self . proxy_pool . filter_working_proxies ()
self . proxy_session = ProxySession ( self . proxy_pool )
def request_function ( self , ** kwargs ):
try :
response = self . proxy_session . request ( ** kwargs )
print ( f"IP Address: { response . json ()[ 'origin' ] } " )
except Exception as e :
print ( f"An error occurred: { str ( e ) } " )
if __name__ == "__main__" :
project = Project ()
project . request_function ( url = "https://httpbin.org/ip" , method = "GET" )欢迎捐款!如果您有改进或其他功能的建议,请随时打开问题或提交拉动请求。
该项目已根据MIT许可获得许可。有关详细信息,请参见许可证文件。