fix: changed proxy function

This commit is contained in:
VinciGit00 2024-04-27 14:40:50 +02:00
parent f6077d1f98
commit b754dd909c
3 changed files with 7 additions and 8 deletions

View File

@ -7,7 +7,7 @@ from langchain_community.document_loaders import AsyncHtmlLoader
from langchain_core.documents import Document from langchain_core.documents import Document
from .base_node import BaseNode from .base_node import BaseNode
from ..utils.remover import remover from ..utils.remover import remover
from ..utils.proxy_rotation import proxy_rotation from ..utils.proxy_generator import proxy_generator
class FetchNode(BaseNode): class FetchNode(BaseNode):
@ -84,7 +84,7 @@ class FetchNode(BaseNode):
else: else:
if self.num_prox > 1: if self.num_prox > 1:
loader = AsyncHtmlLoader( loader = AsyncHtmlLoader(
source, proxies=proxy_rotation(self.num_prox)) source, proxies=proxy_generator(self.num_prox))
else: else:
loader = AsyncHtmlLoader(source) loader = AsyncHtmlLoader(source)
document = loader.load() document = loader.load()

View File

@ -5,4 +5,4 @@ from .save_audio_from_bytes import save_audio_from_bytes
from .convert_to_csv import convert_to_csv from .convert_to_csv import convert_to_csv
from .convert_to_json import convert_to_json from .convert_to_json import convert_to_json
from .prettify_exec_info import prettify_exec_info from .prettify_exec_info import prettify_exec_info
from .proxy_rotation import proxy_rotation from .proxy_generator import proxy_generator

View File

@ -4,7 +4,7 @@ Module for rotating proxies
from fp.fp import FreeProxy from fp.fp import FreeProxy
def proxy_rotation(num_ips: int): def proxy_generator(num_ips: int):
""" """
Rotates through a specified number of proxy IPs using the FreeProxy library. Rotates through a specified number of proxy IPs using the FreeProxy library.
@ -15,7 +15,7 @@ def proxy_rotation(num_ips: int):
dict: A dictionary containing the rotated proxy IPs, indexed by their position in rotation. dict: A dictionary containing the rotated proxy IPs, indexed by their position in rotation.
Example: Example:
>>> proxy_rotation(5) >>> proxy_generator(5)
{ {
0: '192.168.1.1:8080', 0: '192.168.1.1:8080',
1: '103.10.63.135:8080', 1: '103.10.63.135:8080',
@ -24,9 +24,8 @@ def proxy_rotation(num_ips: int):
4: '113.20.31.250:8080' 4: '113.20.31.250:8080'
} }
""" """
res = {} res = []
for i in range(0, num_ips): for i in range(0, num_ips):
res[i] = FreeProxy().get() res.append(FreeProxy().get())
return res return res