MCPcopy Create free account
hub / github.com/ScrapeGraphAI/Scrapegraph-ai / search_all

Function search_all

scrapegraphai/utils/proxy_rotation.py:89–129  ·  view source on GitHub ↗
(proxybroker: FreeProxy, k: int, search_outside: bool)

Source from the content-addressed store, hash-verified

87 )
88
89 def search_all(proxybroker: FreeProxy, k: int, search_outside: bool) -> List[str]:
90 candidateset = proxybroker.get_proxy_list(search_outside)
91 random.shuffle(candidateset)
92
93 positive = set()
94
95 for address in candidateset:
96 setting = {proxybroker.schema: f"http://{address}"}
97
98 try:
99 server = proxybroker._FreeProxy__check_if_proxy_is_working(setting)
100
101 if not server:
102 continue
103
104 positive.add(server)
105
106 if len(positive) < k:
107 continue
108
109 return list(positive)
110
111 except requests.exceptions.RequestException:
112 continue
113
114 n = len(positive)
115
116 if n < k and search_outside:
117 proxybroker.country_id = None
118
119 try:
120 negative = set(search_all(proxybroker, k - n, False))
121 except FreeProxyException:
122 negative = set()
123
124 positive = positive | negative
125
126 if not positive:
127 raise FreeProxyException("missing proxy servers for criteria")
128
129 return list(positive)
130
131 return search_all(proxybroker, max_shape, search_outside_if_empty)
132

Callers 1

search_proxy_serversFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected