mirror of
https://github.com/NanmiCoder/MediaCrawler.git
synced 2025-11-25 03:15:17 +08:00
feat: 增加 IP 代理的最新实现
This commit is contained in:
17
test/test_proxy_ip_pool.py
Normal file
17
test/test_proxy_ip_pool.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# @Author : relakkes@gmail.com
|
||||
# @Time : 2023/12/2 14:42
|
||||
# @Desc :
|
||||
from unittest import IsolatedAsyncioTestCase
|
||||
|
||||
from proxy.proxy_ip_pool import create_ip_pool
|
||||
from proxy.proxy_ip_provider import IpInfoModel
|
||||
|
||||
|
||||
class TestIpPool(IsolatedAsyncioTestCase):
|
||||
async def test_ip_pool(self):
|
||||
pool = await create_ip_pool(ip_pool_count=30, enable_validate_ip=False)
|
||||
for i in range(30):
|
||||
ip_proxy_info: IpInfoModel = await pool.get_proxy()
|
||||
self.assertIsNotNone(ip_proxy_info.ip, msg="验证 ip 是否获取成功")
|
||||
print(ip_proxy_info)
|
||||
Reference in New Issue
Block a user