MCPcopy Index your code
hub / github.com/NanmiCoder/MediaCrawler / create_ip_pool

Function create_ip_pool

proxy/proxy_ip_pool.py:198–218  ·  view source on GitHub ↗

Create IP proxy pool :param ip_pool_count: Number of IPs in the pool :param enable_validate_ip: Whether to enable IP proxy validation :return:

(ip_pool_count: int, enable_validate_ip: bool)

Source from the content-addressed store, hash-verified

196
197
198async def create_ip_pool(ip_pool_count: int, enable_validate_ip: bool) -> ProxyIpPool:
199 """
200 Create IP proxy pool
201 :param ip_pool_count: Number of IPs in the pool
202 :param enable_validate_ip: Whether to enable IP proxy validation
203 :return:
204 """
205 ip_provider = IpProxyProvider.get(config.IP_PROXY_PROVIDER_NAME)
206 if ip_provider is None:
207 raise ValueError(
208 f"Unknown proxy provider: '{config.IP_PROXY_PROVIDER_NAME}'. "
209 f"Valid options: {list(IpProxyProvider.keys())}"
210 )
211 is_static = config.IP_PROXY_PROVIDER_NAME == ProviderNameEnum.STATIC_PROVIDER.value
212 pool = ProxyIpPool(
213 ip_pool_count=ip_pool_count,
214 enable_validate_ip=False if is_static else enable_validate_ip,
215 ip_provider=ip_provider,
216 )
217 await pool.load_proxies()
218 return pool
219
220
221if __name__ == "__main__":

Callers 12

test_ip_poolMethod · 0.90
test_ip_expirationMethod · 0.90
startMethod · 0.90
startMethod · 0.90
startMethod · 0.90
startMethod · 0.90
startMethod · 0.90
startMethod · 0.90
startMethod · 0.90

Calls 4

load_proxiesMethod · 0.95
ProxyIpPoolClass · 0.85
getMethod · 0.45
keysMethod · 0.45