mirror of
https://github.com/laramies/theHarvester.git
synced 2024-09-20 15:26:31 +08:00
#1383 fix githubcode.py
This commit is contained in:
parent
b7aba8ed7f
commit
8468e4767f
|
@ -17,7 +17,7 @@ class RetryResult(NamedTuple):
|
||||||
class SuccessResult(NamedTuple):
|
class SuccessResult(NamedTuple):
|
||||||
fragments: List[str]
|
fragments: List[str]
|
||||||
next_page: Union[int, None]
|
next_page: Union[int, None]
|
||||||
last_page: int
|
last_page: Union[int, None]
|
||||||
|
|
||||||
|
|
||||||
class ErrorResult(NamedTuple):
|
class ErrorResult(NamedTuple):
|
||||||
|
@ -32,7 +32,7 @@ def __init__(self, word, limit) -> None:
|
||||||
self.server = "api.github.com"
|
self.server = "api.github.com"
|
||||||
self.limit = limit
|
self.limit = limit
|
||||||
self.counter: int = 0
|
self.counter: int = 0
|
||||||
self.page: int = 1
|
self.page: Union[int, None] = 1
|
||||||
self.key = Core.github_key()
|
self.key = Core.github_key()
|
||||||
# If you don't have a personal access token, GitHub narrows your search capabilities significantly
|
# If you don't have a personal access token, GitHub narrows your search capabilities significantly
|
||||||
# rate limits you more severely
|
# rate limits you more severely
|
||||||
|
@ -71,7 +71,6 @@ async def handle_response(
|
||||||
if status == 200:
|
if status == 200:
|
||||||
results = await self.fragments_from_response(json_data)
|
results = await self.fragments_from_response(json_data)
|
||||||
next_page = await self.page_from_response("next", links)
|
next_page = await self.page_from_response("next", links)
|
||||||
# TODO: figure out what int is last page
|
|
||||||
last_page = await self.page_from_response("last", links)
|
last_page = await self.page_from_response("last", links)
|
||||||
return SuccessResult(results, next_page, last_page)
|
return SuccessResult(results, next_page, last_page)
|
||||||
elif status == 429 or status == 403:
|
elif status == 429 or status == 403:
|
||||||
|
@ -105,7 +104,7 @@ async def do_search(self, page: int) -> Tuple[str, dict, int, Any]:
|
||||||
return await resp.text(), await resp.json(), resp.status, resp.links
|
return await resp.text(), await resp.json(), resp.status, resp.links
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def next_page_or_end(result: SuccessResult) -> int:
|
async def next_page_or_end(result: SuccessResult) -> Union[int, None]:
|
||||||
if result.next_page is not None:
|
if result.next_page is not None:
|
||||||
return result.next_page
|
return result.next_page
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue