Skip to content

Commit

Permalink
Fixed page size for ZoomEye
Browse files Browse the repository at this point in the history
  • Loading branch information
Xewdy444 committed Apr 21, 2024
1 parent fc8c28c commit 3b48c24
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ def __len__(self) -> int:
return len(self._tasks)

def __iter__(self) -> Iterable[asyncio.Task[Any]]:
for task in self._tasks:
yield task
yield from self._tasks

async def __aenter__(self) -> CoroutineExecutor:
return self
Expand Down
9 changes: 4 additions & 5 deletions utils/zoomeye.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import aiohttp

USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"


@dataclass
class ZoomEyeCredentials:
Expand Down Expand Up @@ -36,10 +38,7 @@ def __init__(self, credentials: ZoomEyeCredentials) -> None:
self._session = aiohttp.ClientSession()

self._session.headers.update(
{
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
"API-KEY": credentials.api_key,
}
{"User-Agent": USER_AGENT, "API-KEY": credentials.api_key}
)

def __repr__(self) -> str:
Expand Down Expand Up @@ -102,7 +101,7 @@ async def get_hosts(self, query: str, *, count: int = 500) -> List[Tuple[str, in
"""
tasks = [
asyncio.create_task(self.search(query, page=page))
for page in range(1, math.ceil(count / 20) + 1)
for page in range(1, math.ceil(count / 10) + 1)
]

results = await asyncio.gather(*tasks)
Expand Down

0 comments on commit 3b48c24

Please sign in to comment.