@@ -32,6 +32,7 @@ def to_requests_dict(self) -> RequestsProxyConfigDict:
3232 """
3333 pass
3434
35+ @property
3536 def prevent_keeping_connections_alive (self ) -> bool :
3637 """
3738 If you are using rotating proxies, it can be useful to prevent the HTTP
@@ -40,6 +41,16 @@ def prevent_keeping_connections_alive(self) -> bool:
4041 """
4142 return False
4243
44+ @property
45+ def retries_when_blocked (self ) -> int :
46+ """
47+ Defines how many times we should retry if a request is blocked. When using
48+ rotating residential proxies with a large IP pool it can make sense to retry a
49+ couple of times when a blocked IP is encountered, since a retry will trigger
50+ an IP rotation and the next IP might not be blocked.
51+ """
52+ return 0
53+
4354
4455class GenericProxyConfig (ProxyConfig ):
4556 """
@@ -83,8 +94,9 @@ class WebshareProxyConfig(GenericProxyConfig):
8394 most reliable way to work around being blocked by YouTube.
8495
8596 If you don't have a Webshare account yet, you will have to create one
86- at https://www.webshare.io/?referral_code=w0xno53eb50g and purchase a residential
87- proxy package that suits your workload, to be able to use this proxy config.
97+ at https://www.webshare.io/?referral_code=w0xno53eb50g and purchase a "Residential"
98+ proxy package that suits your workload, to be able to use this proxy config (make
99+ sure NOT to purchase "Proxy Server" or "Static Residential"!).
88100
89101 Once you have created an account you only need the "Proxy Username" and
90102 "Proxy Password" that you can find in your Webshare settings
@@ -105,24 +117,33 @@ def __init__(
105117 self ,
106118 proxy_username : str ,
107119 proxy_password : str ,
120+ retries_when_blocked : int = 10 ,
108121 domain_name : str = DEFAULT_DOMAIN_NAME ,
109122 proxy_port : int = DEFAULT_PORT ,
110123 ):
111124 """
112125 Once you have created a Webshare account at
113- https://www.webshare.io/?referral_code=w0xno53eb50g and purchased a residential
114- proxy package, this config class allows you to easily use it, by defaulting to
115- the most reliable proxy settings (rotating residential proxies).
126+ https://www.webshare.io/?referral_code=w0xno53eb50g and purchased a
127+ "Residential" package (make sure NOT to purchase "Proxy Server" or
128+ "Static Residential"!), this config class allows you to easily use it,
129+ by defaulting to the most reliable proxy settings (rotating residential
130+ proxies).
116131
117132 :param proxy_username: "Proxy Username" found at
118133 https://dashboard.webshare.io/proxy/settings
119134 :param proxy_password: "Proxy Password" found at
120135 https://dashboard.webshare.io/proxy/settings
136+ :param retries_when_blocked: Define how many times we should retry if a request
137+ is blocked. When using rotating residential proxies with a large IP pool it
138+ makes sense to retry a couple of times when a blocked IP is encountered,
139+ since a retry will trigger an IP rotation and the next IP might not be
140+ blocked. Defaults to 10.
121141 """
122142 self .proxy_username = proxy_username
123143 self .proxy_password = proxy_password
124144 self .domain_name = domain_name
125145 self .proxy_port = proxy_port
146+ self ._retries_when_blocked = retries_when_blocked
126147
127148 @property
128149 def url (self ) -> str :
@@ -139,5 +160,10 @@ def http_url(self) -> str:
139160 def https_url (self ) -> str :
140161 return self .url
141162
163+ @property
142164 def prevent_keeping_connections_alive (self ) -> bool :
143165 return True
166+
167+ @property
168+ def retries_when_blocked (self ) -> int :
169+ return self ._retries_when_blocked
0 commit comments