mirror of
https://github.com/laramies/theHarvester.git
synced 2026-09-23 10:04:56 +02:00
fix typing for core fetch_all
This commit is contained in:
@@ -8,7 +8,7 @@ from theHarvester.parsers import myparser
|
||||
class SearchBing:
|
||||
def __init__(self, word, limit, start) -> None:
|
||||
self.word = word.replace(" ", "%20")
|
||||
self.results: tuple[Any, ...] = ()
|
||||
self.results: list[Any] = []
|
||||
self.total_results = ""
|
||||
self.server = "www.bing.com"
|
||||
self.apiserver = "api.search.live.net"
|
||||
|
||||
@@ -93,11 +93,10 @@ class TakeOver:
|
||||
http_hosts = [f"http://{host}" for host in self.hosts]
|
||||
all_hosts = https_hosts + http_hosts
|
||||
shuffle(all_hosts)
|
||||
tup_resps = await AsyncFetcher.fetch_all(
|
||||
resps: list = await AsyncFetcher.fetch_all(
|
||||
all_hosts, takeover=True, proxy=self.proxy
|
||||
)
|
||||
tup_resps = tuple(tup for tup in tup_resps if len(tup[1]) >= 1)
|
||||
for url, resp in tup_resps:
|
||||
for url, resp in tuple(resp for resp in resps if len(resp[1]) >= 1):
|
||||
await self.check(url, resp)
|
||||
else:
|
||||
return
|
||||
|
||||
@@ -439,7 +439,7 @@ class AsyncFetcher:
|
||||
json: bool = False,
|
||||
takeover: bool = False,
|
||||
proxy: bool = False,
|
||||
) -> tuple:
|
||||
) -> list:
|
||||
# By default, timeout is 5 minutes; 60 seconds should suffice
|
||||
timeout = aiohttp.ClientTimeout(total=60)
|
||||
if len(headers) == 0:
|
||||
@@ -449,7 +449,7 @@ class AsyncFetcher:
|
||||
headers=headers, timeout=aiohttp.ClientTimeout(total=15)
|
||||
) as session:
|
||||
if proxy:
|
||||
tuples = await asyncio.gather(
|
||||
return await asyncio.gather(
|
||||
*[
|
||||
AsyncFetcher.takeover_fetch(
|
||||
session, url, proxy=random.choice(cls().proxy_list)
|
||||
@@ -457,19 +457,17 @@ class AsyncFetcher:
|
||||
for url in urls
|
||||
]
|
||||
)
|
||||
return tuples
|
||||
else:
|
||||
tuples = await asyncio.gather(
|
||||
return await asyncio.gather(
|
||||
*[AsyncFetcher.takeover_fetch(session, url) for url in urls]
|
||||
)
|
||||
return tuples
|
||||
|
||||
if len(params) == 0:
|
||||
async with aiohttp.ClientSession(
|
||||
headers=headers, timeout=timeout
|
||||
) as session:
|
||||
if proxy:
|
||||
texts = await asyncio.gather(
|
||||
return await asyncio.gather(
|
||||
*[
|
||||
AsyncFetcher.fetch(
|
||||
session,
|
||||
@@ -480,19 +478,17 @@ class AsyncFetcher:
|
||||
for url in urls
|
||||
]
|
||||
)
|
||||
return texts
|
||||
else:
|
||||
texts = await asyncio.gather(
|
||||
return await asyncio.gather(
|
||||
*[AsyncFetcher.fetch(session, url, json=json) for url in urls]
|
||||
)
|
||||
return texts
|
||||
else:
|
||||
# Indicates the request has certain params
|
||||
async with aiohttp.ClientSession(
|
||||
headers=headers, timeout=timeout
|
||||
) as session:
|
||||
if proxy:
|
||||
texts = await asyncio.gather(
|
||||
return await asyncio.gather(
|
||||
*[
|
||||
AsyncFetcher.fetch(
|
||||
session,
|
||||
@@ -504,12 +500,10 @@ class AsyncFetcher:
|
||||
for url in urls
|
||||
]
|
||||
)
|
||||
return texts
|
||||
else:
|
||||
texts = await asyncio.gather(
|
||||
return await asyncio.gather(
|
||||
*[
|
||||
AsyncFetcher.fetch(session, url, params, json)
|
||||
for url in urls
|
||||
]
|
||||
)
|
||||
return texts
|
||||
|
||||
Reference in New Issue
Block a user