Skip to content

Commit b754dd9

Browse files
committed
fix: changed proxy function
1 parent f6077d1 commit b754dd9

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

scrapegraphai/nodes/fetch_node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from langchain_core.documents import Document
88
from .base_node import BaseNode
99
from ..utils.remover import remover
10-
from ..utils.proxy_rotation import proxy_rotation
10+
from ..utils.proxy_generator import proxy_generator
1111

1212

1313
class FetchNode(BaseNode):
@@ -84,7 +84,7 @@ def execute(self, state):
8484
else:
8585
if self.num_prox > 1:
8686
loader = AsyncHtmlLoader(
87-
source, proxies=proxy_rotation(self.num_prox))
87+
source, proxies=proxy_generator(self.num_prox))
8888
else:
8989
loader = AsyncHtmlLoader(source)
9090
document = loader.load()

scrapegraphai/utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
from .convert_to_csv import convert_to_csv
66
from .convert_to_json import convert_to_json
77
from .prettify_exec_info import prettify_exec_info
8-
from .proxy_rotation import proxy_rotation
8+
from .proxy_generator import proxy_generator

scrapegraphai/utils/proxy_rotation.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from fp.fp import FreeProxy
55

66

7-
def proxy_rotation(num_ips: int):
7+
def proxy_generator(num_ips: int):
88
"""
99
Rotates through a specified number of proxy IPs using the FreeProxy library.
1010
@@ -15,7 +15,7 @@ def proxy_rotation(num_ips: int):
1515
dict: A dictionary containing the rotated proxy IPs, indexed by their position in rotation.
1616
1717
Example:
18-
>>> proxy_rotation(5)
18+
>>> proxy_generator(5)
1919
{
2020
0: '192.168.1.1:8080',
2121
1: '103.10.63.135:8080',
@@ -24,9 +24,8 @@ def proxy_rotation(num_ips: int):
2424
4: '113.20.31.250:8080'
2525
}
2626
"""
27-
res = {}
27+
res = []
2828

2929
for i in range(0, num_ips):
30-
res[i] = FreeProxy().get()
31-
30+
res.append(FreeProxy().get())
3231
return res

0 commit comments

Comments
 (0)